Event emitter warning when `SWIPL` is instantiated too many times in the same process
jeswr opened this issue · 3 comments
jeswr commented
If I run
const SWIPL = require('swipl-wasm');
async function main() {
for (let i = 0; i < 11; i += 1) {
await SWIPL({ arguments: ['-q'] })
}
}
main();
Then I receive the warning
(node:29436) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 uncaughtException listeners added to [process]. Use emitter.setMaxListeners() to increase limit
(Use `node --trace-warnings ...` to show where the warning was created)
(node:29436) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 unhandledRejection listeners added to [process]. Use emitter.setMaxListeners() to increase limit
jeswr commented
The full debug log is
jesse@ranchmorty:~/Documents/github/next-swipl-wasm/e3/e4/eyereasoner$ node --trace-warnings listener.js
(node:29982) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 uncaughtException listeners added to [process]. Use emitter.setMaxListeners() to increase limit
at _addListener (node:events:587:17)
at process.addListener (node:events:605:10)
at /home/jesse/Documents/github/next-swipl-wasm/e3/e4/eyereasoner/node_modules/swipl-wasm/dist/swipl/swipl-bundle.js:9:2792
at main (/home/jesse/Documents/github/next-swipl-wasm/e3/e4/eyereasoner/listener.js:5:11)
(node:29982) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 unhandledRejection listeners added to [process]. Use emitter.setMaxListeners() to increase limit
at _addListener (node:events:587:17)
at process.addListener (node:events:605:10)
at /home/jesse/Documents/github/next-swipl-wasm/e3/e4/eyereasoner/node_modules/swipl-wasm/dist/swipl/swipl-bundle.js:9:2883
at main (/home/jesse/Documents/github/next-swipl-wasm/e3/e4/eyereasoner/listener.js:5:11)
which corresponds to the following line in the bundle
process["on"]("uncaughtException",function(ex){if(!(ex instanceof ExitStatus)){throw ex}}
which appears to be some of the code generated by Emscripten
jeswr commented
It would appear to correspond to this upstream issue emscripten-core/emscripten#18659
jeswr commented
This and the associated memory leak issue are resolved as of https://github.com/SWI-Prolog/npm-swipl-wasm/releases/tag/v3.2.2