summaryrefslogtreecommitdiff
path: root/ext/node/polyfills
diff options
context:
space:
mode:
authorSatya Rohith <me@satyarohith.com>2024-06-10 20:00:56 +0530
committerGitHub <noreply@github.com>2024-06-10 16:30:56 +0200
commit4fd3d5a86e45c4dcbaaa277cfb7f1087ddebfa48 (patch)
tree1540c8e62d50f61a83647831f9beea2837a0299f /ext/node/polyfills
parent3be0a1e8b44782b2d3c3970e0e6fa7fb11be8131 (diff)
fix(ext/node): send data frame with end_stream flag on _final call (#24147)
Diffstat (limited to 'ext/node/polyfills')
-rw-r--r--ext/node/polyfills/http2.ts23
1 files changed, 19 insertions, 4 deletions
diff --git a/ext/node/polyfills/http2.ts b/ext/node/polyfills/http2.ts
index 7a9d91097..2a3b4f7f3 100644
--- a/ext/node/polyfills/http2.ts
+++ b/ext/node/polyfills/http2.ts
@@ -978,7 +978,7 @@ export class ClientHttp2Stream extends Duplex {
return;
}
- shutdownWritable(this, cb);
+ shutdownWritable(this, cb, this.#rid);
}
// TODO(bartlomieju): needs a proper cleanup
@@ -1176,15 +1176,30 @@ export class ClientHttp2Stream extends Duplex {
}
}
-function shutdownWritable(stream, callback) {
+function shutdownWritable(stream, callback, streamRid) {
debugHttp2(">>> shutdownWritable", callback);
const state = stream[kState];
if (state.shutdownWritableCalled) {
+ debugHttp2(">>> shutdownWritable() already called");
return callback();
}
state.shutdownWritableCalled = true;
- onStreamTrailers(stream);
- callback();
+ if (state.flags & STREAM_FLAGS_HAS_TRAILERS) {
+ onStreamTrailers(stream);
+ callback();
+ } else {
+ op_http2_client_send_data(streamRid, new Uint8Array(), true)
+ .then(() => {
+ callback();
+ stream[kMaybeDestroy]();
+ core.tryClose(streamRid);
+ })
+ .catch((e) => {
+ callback(e);
+ core.tryClose(streamRid);
+ stream._destroy(e);
+ });
+ }
// TODO(bartlomieju): might have to add "finish" event listener here,
// check it.
}