Skip to content

Commit 10edc4f

Browse files
addaleaxBridgeAR
authored andcommitted
net: always invoke after-write callback
This is part of the streams API contract, and aligns network sockets with other streams in this respect. PR-URL: #24291 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Weijia Wang <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent eeb5cc6 commit 10edc4f

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

lib/net.js

+2
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,8 @@ function afterWrite(status, handle, err) {
790790
// callback may come after call to destroy.
791791
if (self.destroyed) {
792792
debug('afterWrite destroyed');
793+
if (this.callback)
794+
this.callback(null);
793795
return;
794796
}
795797

test/parallel/test-tls-invoke-queued.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ const server = tls.createServer({
4040
c.write('world!', null, common.mustCall(function() {
4141
c.destroy();
4242
}));
43-
// Data on next _write() will be written but callback will not be invoked
44-
c.write(' gosh', null, common.mustNotCall());
43+
// Data on next _write() will be written, and the cb will still be invoked
44+
c.write(' gosh', null, common.mustCall());
4545
}));
4646

4747
server.close();

0 commit comments

Comments
 (0)