-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Description
I don't think it is a good idea that a call to Writable.destroy will invoke Writable._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.