Closed jason-codaio closed 4 years ago
I'm going to close this out, but I wanted to summarize what I found. Basically we were CPU locking the main thread despite awaiting 16M+ async functions. I added a smartly placed setImmediate
into our event loop and the problem has gone away as we make sure we give the garbage collector time to run.
We apparently had this time bomb since we migrated from Bluebird
promises to native promises.
I've notice during some active payloads we are generating a large number of async promises which ends up filling up the context map here:
https://github.com/Jeff-Lewis/cls-hooked/blob/master/context.js#L316
This happens after the Map has
16777216
entries and it throws aRangeError
when you try to insert another. I've confirmed the hooks are not leaking as they are in the node queue to be destroyed its just that garbage collection has not been called yet.....Any thoughts on how to mitigate or more gracefully fall back?