Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MemoryLeak due to long await in CertificateService issue method of @energyweb/origin-247-certificate package's causing, when trying to issue around 50 certificates #3368

Open
Ahmed-Suhail opened this issue Nov 28, 2022 · 2 comments

Comments

@Ahmed-Suhail
Copy link

Description

When using issue method of CertificateService of @energyweb/origin-247-certificate package, we are triggering this method to issue certificates in our system. This warning doesnt comes when we issue 2-5 certificates especially we try to issue more certificates like 50 we get the below warning

Warning in Console

MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 global:completed listeners added to [Queue]. Use emitter.setMaxListeners() to increase limit
at _addListener (events.js:475:17)
at Queue.addListener (events.js:497:10)
at Queue.on (/var/deployment/common/temp/node_modules/.pnpm/[email protected]/node_modules/bull/lib/queue.js:326:14)
at /var/deployment/common/temp/node_modules/.pnpm/[email protected]/node_modules/bull/lib/job.js:504:18
at new Promise ()
at Job.finished (/var/deployment/common/temp/node_modules/.pnpm/[email protected]/node_modules/bull/lib/job.js:480:12)
at runMicrotasks ()
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async CertificateService.waitForJobResult (/var/deployment/common/temp/node_modules/.pnpm/@energyweb[email protected]_a1b67e60083a0f64adab87445ef00c80/node_modules/@energyweb/origin-247-certificate/dist/js/src/certificate.service.js:111:20)
at async CertificateService.issue (/var/deployment/common/temp/node_modules/.pnpm/@energyweb[email protected]_a1b67e60083a0f64adab87445ef00c80/node_modules/@energyweb/origin-247-certificate/dist/js/src/certificate.service.js:48:24)
(node:1) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 global:failed listeners added to [Queue]. Use emitter.setMaxListeners() to increase limit

Alernate Solution

We can have alternate method which doesnt awaits for the job to complete but just puts the job on queue and returns.
Due to long await waitForJobResult we are getting MemoryLeak

This is snippet in issue method of CertificateService of @energyweb/origin-247-certificate
const job = await this.blockchainActionsQueue.add({
payload: command,
type: types_1.BlockchainActionType.Issuance
}, jobOptions);
const result = await this.waitForJobResult(job);

@JonaszJestem
Copy link
Contributor

Have you tried batching the certificates and using batchIssue method?

@Ahmed-Suhail
Copy link
Author

I havent tried that but we have different reservations for different devices coming up at different times and they all get queued one after another as of now our system is using issue method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants