Skip to content
Closed
Show file tree
Hide file tree
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
Prev Previous commit
Next Next commit
fixup: comment + linting
  • Loading branch information
ronag committed Dec 7, 2019
commit 614ba71a5d4b8488d0db4963926d0b5f949720e2
6 changes: 5 additions & 1 deletion lib/_stream_writable.js
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,10 @@ function onwriteError(stream, state, er, cb) {
--state.pendingcb;

cb(er);
// Ensure callbacks are invoked even when autoDestroy is
// not enabled. Passing `er` here doesn't make sense since
// it's related to one specific write, not to the buffered
// writes.
errorBuffer(state, new ERR_STREAM_DESTROYED('write'));
Comment thread
ronag marked this conversation as resolved.
Outdated
// This can emit error, but error must always follow cb.
errorOrDestroy(stream, er);
Expand Down Expand Up @@ -543,7 +547,7 @@ function afterWrite(stream, state, count, cb) {
}

// If there's something in the buffer waiting, then invoke callbacks.
function errorBuffer (state, err) {
function errorBuffer(state, err) {
for (let entry = state.bufferedRequest; entry; entry = entry.next) {
process.nextTick(entry.callback, err);
}
Expand Down
8 changes: 4 additions & 4 deletions test/parallel/test-stream-writable-destroy.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,14 +355,14 @@ const assert = require('assert');
autoDestroy: false
});
write.cork();
write.write('asd', common.mustCall(err => {
write.write('asd', common.mustCall((err) => {
assert.strictEqual(err.message, 'asd');
}));
write.write('asd', common.mustCall(err => {
write.write('asd', common.mustCall((err) => {
assert.strictEqual(err.code, 'ERR_STREAM_DESTROYED');
}));
write.on('error', common.mustCall(err => {
write.on('error', common.mustCall((err) => {
assert.strictEqual(err.message, 'asd');
}))
}));
write.uncork();
}