Open achingbrain opened 2 years ago
I believe the problem lies in this method: https://github.com/alxhotel/nat-api/blob/e404453ebca7e386fbd20f8dd7d86b8c9611058e/index.js#L312
Specifically, here: https://github.com/alxhotel/nat-api/blob/e404453ebca7e386fbd20f8dd7d86b8c9611058e/index.js#L327-L332
When autoupdate is enabled (default behavior), _upnpMap
gets called at regular intervals and, each time it executes, it adds an additional timer. This means that, over time, you get more and more _upnpMap
calls firing at the same time, until you reach a point where the underlying code registers too many listeners in a short amount of time.
Partially related: I feel like the same could happen if you map too many ports with the same TTL. You would have a spike in the number of listeners, except that in this case there is no leak because listeners are correctly unregistered.
@alxhotel, any chance you can have a look at my analysis? I'll be happy to create a PR.
After about 10 hours running I start seeing
MaxListenersExceededWarning
: