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: https://github.com/nodejs/node/pull/24291 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Weijia Wang <starkwang@126.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
parent
3212f77ac6
commit
c347e77647
@ -790,6 +790,8 @@ function afterWrite(status, handle, err) {
|
||||
// callback may come after call to destroy.
|
||||
if (self.destroyed) {
|
||||
debug('afterWrite destroyed');
|
||||
if (this.callback)
|
||||
this.callback(null);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -40,8 +40,8 @@ const server = tls.createServer({
|
||||
c.write('world!', null, common.mustCall(function() {
|
||||
c.destroy();
|
||||
}));
|
||||
// Data on next _write() will be written but callback will not be invoked
|
||||
c.write(' gosh', null, common.mustNotCall());
|
||||
// Data on next _write() will be written, and the cb will still be invoked
|
||||
c.write(' gosh', null, common.mustCall());
|
||||
}));
|
||||
|
||||
server.close();
|
||||
|
Loading…
x
Reference in New Issue
Block a user