Aliheym / typeorm-transactional

A Transactional Method Decorator for TypeORM that uses Async Local Storage or cls-hooked to handle and propagate transactions between different repositories and service methods.
MIT License
201 stars 27 forks source link

EventEmitter memory leak detected #13

Closed herenickname closed 1 year ago

herenickname commented 1 year ago

I use a lot of runOnTransactionCommit hooks, so I caught this warning at runtime:

(node:25728) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 commit listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit
    at _addListener (node:events:587:17)
    at EventEmitter.addListener (node:events:605:10)
    at EventEmitter.added (/root/v3/node_modules/emitter-listener/listener.js:93:27)
    at EventEmitter.once (node:events:649:8)
    at runOnTransactionCommit (/root/v3/node_modules/typeorm-transactional/dist/hooks/index.js:103:48)

It would be nice if you open events' method setMaxListeners publicly available to manage.

Thanks for this fork and your work.

Aliheym commented 1 year ago

Hi, thanks for your issue.

I added options maxHookHandlers to handle this issue in new version.

  initializeTransactionalContext({ maxHookHandlers: 0 });
herenickname commented 1 year ago

Hi, thanks for your issue.

I added options maxHookHandlers to handle this issue in new version.

  initializeTransactionalContext({ maxHookHandlers: 0 });

Seems its still not implemented :(