Unverified Commit e7cb694a authored by Anna Henningsen's avatar Anna Henningsen
Browse files

stream: always reset awaitDrain when emitting data

The complicated `awaitDrain` machinery can be made a bit
slimmer, and more correct, by just resetting the value
each time `stream.emit('data')` is called.

By resetting the value before emitting the data chunk, and
seeing whether any pipe destinations return `.write() === false`,
we always end up in a consistent state and don’t need to worry
about odd situations (like `dest.write(chunk)` emitting more data).

PR-URL: https://github.com/nodejs/node/pull/18516
Fixes: https://github.com/nodejs/node/issues/18484
Fixes: https://github.com/nodejs/node/issues/18512
Refs: https://github.com/nodejs/node/pull/18515


Reviewed-By: default avatarAnatoli Papirovski <apapirovski@mac.com>
Reviewed-By: default avatarMatteo Collina <matteo.collina@gmail.com>
Reviewed-By: default avatarJames M Snell <jasnell@gmail.com>
Reviewed-By: default avatarMinwoo Jung <minwoo@nodesource.com>
Reviewed-By: default avatarRuben Bridgewater <ruben@bridgewater.de>
parent 610cac26
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment