Skip to content
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

Check added for destroyed stream in onwrite function #48772

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/internal/streams/writable.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ Writable.prototype.pipe = function() {

function _write(stream, chunk, encoding, cb) {
const state = stream._writableState;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please restore this

if (typeof encoding === 'function') {
cb = encoding;
encoding = state.defaultEncoding;
Expand Down Expand Up @@ -436,7 +436,11 @@ function onwrite(stream, er) {
const state = stream._writableState;
const sync = state.sync;
const cb = state.writecb;


if(state.destroyed){
throw new ERR_STREAM_DESTROYED('write');
return;
}
if (typeof cb !== 'function') {
errorOrDestroy(stream, new ERR_MULTIPLE_CALLBACK());
return;
Expand Down