mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
stream: relocate the status checking code in the onwritecomplete
relocate the status checking code before verifying if the stream is destroyed PR-URL: https://github.com/nodejs/node/pull/54032 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
294ae14b98
commit
298dea0c63
@ -83,23 +83,21 @@ function onWriteComplete(status) {
|
|||||||
|
|
||||||
const stream = this.handle[owner_symbol];
|
const stream = this.handle[owner_symbol];
|
||||||
|
|
||||||
|
if (status < 0) {
|
||||||
|
const error = new ErrnoException(status, 'write', this.error);
|
||||||
|
if (typeof this.callback === 'function') {
|
||||||
|
return this.callback(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
return stream.destroy(error);
|
||||||
|
}
|
||||||
|
|
||||||
if (stream.destroyed) {
|
if (stream.destroyed) {
|
||||||
if (typeof this.callback === 'function')
|
if (typeof this.callback === 'function')
|
||||||
this.callback(null);
|
this.callback(null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO (ronag): This should be moved before if(stream.destroyed)
|
|
||||||
// in order to avoid swallowing error.
|
|
||||||
if (status < 0) {
|
|
||||||
const ex = new ErrnoException(status, 'write', this.error);
|
|
||||||
if (typeof this.callback === 'function')
|
|
||||||
this.callback(ex);
|
|
||||||
else
|
|
||||||
stream.destroy(ex);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
stream[kUpdateTimer]();
|
stream[kUpdateTimer]();
|
||||||
stream[kAfterAsyncWrite](this);
|
stream[kAfterAsyncWrite](this);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user