Skip to content

Commit fa691f7

Browse files
committed
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: #18676 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent efb4646 commit fa691f7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/internal/wrap_js_stream.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ class JSStreamWrap extends Socket {
137137
doWrite(req, bufs) {
138138
assert.strictEqual(this[kCurrentWriteRequest], null);
139139
assert.strictEqual(this[kCurrentShutdownRequest], null);
140-
this[kCurrentWriteRequest] = req;
141140

142141
const handle = this._handle;
143142
const self = this;
@@ -149,6 +148,9 @@ class JSStreamWrap extends Socket {
149148
this.stream.write(bufs[i], done);
150149
this.stream.uncork();
151150

151+
// Only set the request here, because the `write()` calls could throw.
152+
this[kCurrentWriteRequest] = req;
153+
152154
function done(err) {
153155
if (!err && --pending !== 0)
154156
return;

0 commit comments

Comments
 (0)