amqp / rhea-promise

A promisified layer over rhea AMQP client
Apache License 2.0
30 stars 19 forks source link

Set the max listener limit to 1000 for `RheaConnection` #110

Closed the-ress closed 4 months ago

the-ress commented 5 months ago

Description

NodeJS would issue warning if the number of disconnected listeners on an event emitter exceeds 10. When many sessions or links on a connection are closed at the same time, we will see this warning because the default limit of 10 in NodeJS is too low. The disconnected listeners DO get removed eventually.

This causes Azure/azure-sdk-for-js#29186 when it stops all its Link objects at the same time. (Source links: Link.stop call, the loop)

azure-sdk-for-js already raises the limit this for some other objects. Since Connection._connection is private and the disconnect listeners are an implementation detail of rhea-promise, I felt it was more appropriate to address it here.

There's also a draft PR #78 from 2021 trying to address this issue, but it looks a lot like (partially) reimplementing EventEmitter just to remove the listener warning. That's why I ultimately decided to go with setMaxListeners.

Brief description of the changes made in the PR. This helps in making better changelog

Reference to any github issues

jeremymeng commented 4 months ago

Thanks for the PR @the-ress!