src: only set JSStreamWrap write req after write()
Otherwise `this[kCurrentWriteRequest]` is set to a value even if one of the `write` calls throws. This is needed in order not to break tests in a later commit. PR-URL: https://github.com/nodejs/node/pull/18676 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
82c43aed16
commit
e1271c07c3
@ -137,7 +137,6 @@ class JSStreamWrap extends Socket {
|
||||
doWrite(req, bufs) {
|
||||
assert.strictEqual(this[kCurrentWriteRequest], null);
|
||||
assert.strictEqual(this[kCurrentShutdownRequest], null);
|
||||
this[kCurrentWriteRequest] = req;
|
||||
|
||||
const handle = this._handle;
|
||||
const self = this;
|
||||
@ -149,6 +148,9 @@ class JSStreamWrap extends Socket {
|
||||
this.stream.write(bufs[i], done);
|
||||
this.stream.uncork();
|
||||
|
||||
// Only set the request here, because the `write()` calls could throw.
|
||||
this[kCurrentWriteRequest] = req;
|
||||
|
||||
function done(err) {
|
||||
if (!err && --pending !== 0)
|
||||
return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user