Skip to content

Commit

Permalink
fixup: tls test + writable write complete err
Browse files Browse the repository at this point in the history
  • Loading branch information
ronag committed Feb 29, 2020
1 parent c020324 commit 80cf7f6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
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;

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();
}));
}));

0 comments on commit 80cf7f6

Please sign in to comment.