-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stream: Writable should not invoke _destroy while pending ops #29044
Comments
ping @mcollina thoughts? |
destroy() is an immediate action. I’m -1 in having it to wait. |
@mcollina: What about pending operations? I would argue that we cannot make |
I might be ok in adding an option to write |
But how? We can't guarantee that since we can't cancel already dispatched
Maybe some kind of timeout? Which is the responsibility of the I understand how you would like it to work. But I don't see how we can make it work like that. #29028 will only ensure that buffered requests are not dispatched. Not that already dispatched requests will be cancelled. |
I would like to refer to this issue #2006 which illustrates the problem. The way it was solved is kind of a hack where destroy doesn't actually destroy (https://github.com/nodejs/node/blob/master/lib/internal/fs/streams.js#L392). |
Let's take a |
Hm, that makes sense. Thank you for explaining. |
I don't think it is a good idea that a call to
Writable.destroy
will invokeWritable._destroy
while there are still active/pending_write
&_writev
(or_read
for that matter). Since these might be working on resources that might be closed and cause invalid state.We have already encountered this problem with
fs
writable streams (#2006). The solution there is a bit of a "hack". I'm sure the same problem can occur in other userland stream implementations as well as other edge cases (including core streams).I think the "proper" way to resolve this is to invok
Writable._destroy
after all pending operations are complete (e.g.pendingcb === 0
).I don't have a obvious way right now to do this change as it would require inlining the
destroyImpl
helper.I think this applies to
Readable
as well.The text was updated successfully, but these errors were encountered: