-
Notifications
You must be signed in to change notification settings - Fork 59
Description
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);