Skip to content

Commit 79df2ac

Browse files
divybotlittledivy
andauthored
fix(ext/node): emit Buffer for http2 'goaway' opaqueData (#33502)
Enables `test-http2-goaway-opaquedata` in node_compat suite. Co-authored-by: divybot <divybot@users.noreply.github.com> Co-authored-by: Divy Srivastava <me@littledivy.com>
1 parent f47b48b commit 79df2ac

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

ext/node/polyfills/http2.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,13 @@ function onGoawayData(code, lastStreamID, buf) {
781781
state.goawayCode = code;
782782
state.goawayLastStreamID = lastStreamID;
783783

784-
session.emit("goaway", code, lastStreamID, buf);
784+
// Node.js exposes the GOAWAY opaque data as a Buffer, not a plain
785+
// Uint8Array. The native binding hands us a Uint8Array, so wrap it
786+
// as a Buffer (zero-copy) before emitting.
787+
const opaqueData = buf !== undefined
788+
? Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength)
789+
: buf;
790+
session.emit("goaway", code, lastStreamID, opaqueData);
785791
if (code === NGHTTP2_NO_ERROR) {
786792
// If this is a no error goaway, begin shutting down.
787793
// No new streams permitted, but existing streams may

tests/node_compat/config.jsonc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1496,6 +1496,7 @@
14961496
"parallel/test-http2-error-order.js": {},
14971497
"parallel/test-http2-getpackedsettings.js": {},
14981498
"parallel/test-http2-goaway-delayed-request.js": {},
1499+
"parallel/test-http2-goaway-opaquedata.js": {},
14991500
"parallel/test-http2-graceful-close.js": {},
15001501
"parallel/test-http2-head-request.js": {},
15011502
"parallel/test-http2-info-headers.js": {},

0 commit comments

Comments
 (0)