I am trying to upload images to apollo-server-express. but when it done it logs this warning
(node:15112) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 exit listeners added. Use emitter.setMaxListeners() to increase limit
and as I trace it the problem is with fs-capacitor that graphql-upload use
Error: Too many listeners of type "exit" added to EventEmitter. Max is 10 and we've added 11.
| at process.addListener (/opt/anar-back/node_modules/max-listeners-exceeded-warning/index.js:10:19)
| at _fs.default.open (/opt/anar-back/node_modules/graphql-upload/node_modules/fs-capacitor/lib/index.js:140:17)
| at FSReqWrap.args [as oncomplete] (fs.js:140:20)
| Type "Node" is missing a "__resolveType" resolver. Pass false into "resolverValidationOptions.requireResolversForResolveType" to disable this warning.
and as I found graphql-upload already fix it.
but apollo server is still using the old version of graphql-upload
apollo-server-express: ^2.9.16
@EhsanSarshar What was the solution that you closed the issue?
What was the solution that you closed the issue?
Is there any solution?
it is not with apollo-server it's how eventemitter work in node.js. and a leak occurs when you continuously add event listener and not removing them when they are not needed.
the solution is to cleanup event handlers after done.
plz have a check on these blog posts and inshallah your problem will be solve
https://medium.com/@jongleberry/understanding-node-jss-possible-eventemitter-leak-error-message-bc2ee68b24ea
https://nodesource.com/blog/understanding-streams-in-nodejs/
Most helpful comment
it is not with apollo-server it's how eventemitter work in node.js. and a leak occurs when you continuously add event listener and not removing them when they are not needed.
the solution is to cleanup event handlers after done.
plz have a check on these blog posts and inshallah your problem will be solve
https://medium.com/@jongleberry/understanding-node-jss-possible-eventemitter-leak-error-message-bc2ee68b24ea
https://nodesource.com/blog/understanding-streams-in-nodejs/