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
the drained() function wraps existing drain() callback and replace it with the new one, and it only got reset back to noop when killed, imagine if somebody call the await drained() a few thousands times in a for-loop (like a long running process), it will create a huge stack and blow when somebody calls drain() later. that will stop the promise from being resolved or even worse when somebody calls killAndDrain() it will crash.
should use an array instead or use a 3rd party event lib or just cache the drained promise, or at least reset it everytime drained (only mitigate the issue).
function drained () {
if (queue.idle()) {
return new Promise(function (resolve) {
resolve()
})
}
var previousDrain = queue.drain
var p = new Promise(function (resolve) {
queue.drain = function () {
previousDrain()
resolve()
}
})
return p
}
}
The text was updated successfully, but these errors were encountered:
the drained() function wraps existing
drain()
callback and replace it with the new one, and it only got reset back tonoop
when killed, imagine if somebody call theawait drained()
a few thousands times in a for-loop (like a long running process), it will create a huge stack and blow when somebody callsdrain()
later. that will stop the promise from being resolved or even worse when somebody calls killAndDrain() it will crash.should use an array instead or use a 3rd party event lib or just cache the
drained
promise, or at least reset it everytime drained (only mitigate the issue).The text was updated successfully, but these errors were encountered: