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

stream: fix multiple Writable.destroy() calls. #38221

Closed
wants to merge 3 commits into from
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/internal/streams/writable.js
Expand Up @@ -855,10 +855,10 @@ Writable.prototype.destroy = function(err, cb) {

// Invoke pending callbacks.
if (
!state.destroyed && (
state.bufferedIndex < state.buffered.length ||
state[kOnFinished].length
) {
assert(!state.destroyed);
)) {
process.nextTick(errorBuffer, state);
}

Expand Down
11 changes: 11 additions & 0 deletions test/parallel/test-stream-writable-destroy.js
Expand Up @@ -460,3 +460,14 @@ const assert = require('assert');
assert.strictEqual(write.destroyed, true);
}));
}

{
// Destroy twice
const write = new Writable({
write(chunk, enc, cb) { cb(); }
});

write.end(common.mustCall());
write.destroy();
write.destroy();
}