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: tls test + writable write complete err
  • Loading branch information
ronag committed Feb 29, 2020
commit 80cf7f68d517a4bd4d54ba6a27c376a37892acd6
4 changes: 3 additions & 1 deletion lib/_stream_writable.js
Original file line number Diff line number Diff line change
Expand Up @@ -464,9 +464,11 @@ function afterWrite(stream, state, count, cb) {
stream.emit('drain');
}

const err = state.destroyed ? new ERR_STREAM_DESTROYED('write') : undefined;
Comment thread
ronag marked this conversation as resolved.
Outdated

while (count-- > 0) {
state.pendingcb--;
cb();
cb(err);
}

if (state.destroyed) {
Expand Down
11 changes: 6 additions & 5 deletions test/parallel/test-tls-writewrap-leak.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ const server = net.createServer(common.mustCall((c) => {
c.destroy();
})).listen(0, common.mustCall(() => {
const c = tls.connect({ port: server.address().port });
c.on('error', () => {
// Otherwise `.write()` callback won't be invoked.
c._undestroy();
});

c.on('error', common.mustCall((err) => {
assert.strictEqual(err.code, 'ECONNRESET');
server.close();
}));

c.write('hello', common.mustCall((err) => {
assert.strictEqual(err.code, 'ECANCELED');
assert.strictEqual(err.code, 'ERR_STREAM_DESTROYED');
server.close();
}));
}));