You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
parallelMerge() uses Promise.race(), and this call has a memory leak: if the same Promise is passed to race() multiple times, its .then() handler is also attached multiple times.
The details are here: nodejs/node#17469 (it's a Node's wontfix issue).
The easiest way to reproduce is to run the following:
Internally, for every single byte in fileStream, a Promise.race() is called for promises from fileStream's and idleStream's AsyncIterator, and since idleStream does not emit anything, its promise is reused over and over, and then() handlers are stacked on each other. So if we run the profiler and compare memory footprints before the cycle and right before idleStream.destroy() call, we'll see thousands/millions of dangling promises.
I don't quite have a better alternative approach for parallelMerge() to propose... what's more or less clear is that it's not a proper thing to use Promise.race() to merge streams/iterables.
The text was updated successfully, but these errors were encountered:
Hi.
parallelMerge() uses Promise.race(), and this call has a memory leak: if the same Promise is passed to race() multiple times, its .then() handler is also attached multiple times.
The details are here: nodejs/node#17469 (it's a Node's wontfix issue).
The easiest way to reproduce is to run the following:
Internally, for every single byte in fileStream, a Promise.race() is called for promises from fileStream's and idleStream's AsyncIterator, and since idleStream does not emit anything, its promise is reused over and over, and then() handlers are stacked on each other. So if we run the profiler and compare memory footprints before the cycle and right before idleStream.destroy() call, we'll see thousands/millions of dangling promises.
I don't quite have a better alternative approach for parallelMerge() to propose... what's more or less clear is that it's not a proper thing to use Promise.race() to merge streams/iterables.
The text was updated successfully, but these errors were encountered: