Conversation
AbhiPrasad
left a comment
There was a problem hiding this comment.
Approve to unblock, but feels weird to me.
Could you share the memory profile? What was not getting GC'd? The request?
| try { | ||
| DEBUG_BUILD && logger.log('Flushing events...'); | ||
| // We give things that are currently stuck in event processors a tiny bit more time to finish before flushing. 50ms was chosen very unscientifically. | ||
| await new Promise(resolve => setTimeout(resolve, 50)); |
There was a problem hiding this comment.
Can we instead call process.nextTick()? I guess that's not isomorphic though.
Sure thing! I always profiled with 3 snapshots. (In the beginning, I used more to verify but got the same results):
This is what it looked like with the This was after removing it: The important part is a) heap just growing b) At first, I thought we were spreading globals into the timeout or promise but looking into the profile it seems like I can DM you the profile but I won't share it here cause I don't know what is contained in the profile since I have auth tokens hard-coded in the app. |


I honestly don't know why this fixes the memory leak.
I tried using
and
but they both also leak.
Since this was just a nice to have, the best path moving forward is just to remove the artificial delay.
Probably fixes #12317