Repository: denoland/deno
Pull request: fix(ext/node): add "internal/http2/util" module

This module (`"internal/http2/util"`) needs to be exposed as it is directly required in several node compat test cases. (e.g. https://github.com/nodejs/node/blob/44a53759c7b7870cf61a61d07cc3fddef9187606/test/parallel/test-http2-server-socket-destroy.js#L10 )

Changed files:
filename: ext/node/lib.rs
patch: @@ -640,6 +640,7 @@ deno_core::extension!(deno_node,
     "internal/fs/handle.ts",
     "internal/hide_stack_frames.ts",
     "internal/http.ts",
+    "internal/http2/util.ts",
     "internal/idna.ts",
     "internal/net.ts",
     "internal/normalize_encoding.mjs",

filename: ext/node/polyfills/01_require.js
patch: @@ -120,6 +120,7 @@ import internalErrors from "ext:deno_node/internal/errors.ts";
 import internalEventTarget from "ext:deno_node/internal/event_target.mjs";
 import internalFsUtils from "ext:deno_node/internal/fs/utils.mjs";
 import internalHttp from "ext:deno_node/internal/http.ts";
+import internalHttp2Util from "ext:deno_node/internal/http2/util.ts";
 import internalReadlineUtils from "ext:deno_node/internal/readline/utils.mjs";
 import internalStreamsAddAbortSignal from "ext:deno_node/internal/streams/add-abort-signal.js";
 import internalStreamsLazyTransform from "ext:deno_node/internal/streams/lazy_transform.js";
@@ -166,7 +167,7 @@ import zlib from "node:zlib";
 const nativeModuleExports = ObjectCreate(null);
 const builtinModules = [];
 
-// NOTE(bartlomieju): keep this list in sync with `ext/node/polyfill.rs`
+// NOTE(bartlomieju): keep this list in sync with `ext/node/lib.rs`
 function setupBuiltinModules() {
   const nodeModules = {
     "_http_agent": _httpAgent,
@@ -223,6 +224,7 @@ function setupBuiltinModules() {
     "internal/event_target": internalEventTarget,
     "internal/fs/utils": internalFsUtils,
     "internal/http": internalHttp,
+    "internal/http2/util": internalHttp2Util,
     "internal/readline/utils": internalReadlineUtils,
     "internal/streams/add-abort-signal": internalStreamsAddAbortSignal,
     "internal/streams/lazy_transform": internalStreamsLazyTransform,

filename: ext/node/polyfills/http2.ts
patch: @@ -68,6 +68,13 @@ import {
   ERR_STREAM_WRITE_AFTER_END,
 } from "ext:deno_node/internal/errors.ts";
 import { _checkIsHttpToken } from "node:_http_common";
+import {
+  kAuthority,
+  kProtocol,
+  kProxySocket,
+  kRequest,
+  kSocket,
+} from "ext:deno_node/internal/http2/util.ts";
 const {
   StringPrototypeTrim,
   FunctionPrototypeBind,
@@ -83,21 +90,17 @@ const {
 const kSession = Symbol("session");
 const kOptions = Symbol("options");
 const kAlpnProtocol = Symbol("alpnProtocol");
-const kAuthority = Symbol("authority");
 const kEncrypted = Symbol("encrypted");
 const kID = Symbol("id");
 const kInit = Symbol("init");
 const kInfoHeaders = Symbol("sent-info-headers");
 const kOrigin = Symbol("origin");
 const kPendingRequestCalls = Symbol("kPendingRequestCalls");
-const kProtocol = Symbol("protocol");
 const kSentHeaders = Symbol("sent-headers");
 const kSentTrailers = Symbol("sent-trailers");
 const kState = Symbol("state");
 const kType = Symbol("type");
 const kTimeout = Symbol("timeout");
-const kSocket = Symbol("socket");
-const kProxySocket = Symbol("proxySocket");
 
 const kDenoResponse = Symbol("kDenoResponse");
 const kDenoRid = Symbol("kDenoRid");
@@ -2181,7 +2184,6 @@ const kRawTrailers = Symbol("rawTrailers");
 const kSetHeader = Symbol("setHeader");
 const kAppendHeader = Symbol("appendHeader");
 const kAborted = Symbol("aborted");
-const kRequest = Symbol("request");
 
 const streamProxySocketHandler = {
   has(stream, prop) {

filename: ext/node/polyfills/internal/http2/util.ts
patch: @@ -0,0 +1,21 @@
+// Copyright 2018-2025 the Deno authors. MIT license.
+
+import { primordials } from "ext:core/mod.js";
+
+const { Symbol } = primordials;
+
+export const kAuthority = Symbol("authority");
+export const kSensitiveHeaders = Symbol("sensitiveHeaders");
+export const kSocket = Symbol("socket");
+export const kProtocol = Symbol("protocol");
+export const kProxySocket = Symbol("proxySocket");
+export const kRequest = Symbol("request");
+
+export default {
+  kAuthority,
+  kSensitiveHeaders,
+  kSocket,
+  kProtocol,
+  kProxySocket,
+  kRequest,
+};

filename: tests/unit_node/http2_test.ts
patch: @@ -9,6 +9,8 @@ import { join } from "node:path";
 import * as net from "node:net";
 import { assert, assertEquals } from "@std/assert";
 import { curlRequest } from "../unit/test_util.ts";
+import { createRequire } from "node:module";
+const require = createRequire(import.meta.url);
 
 // Increase the timeout for the auto select family to avoid flakiness
 net.setDefaultAutoSelectFamilyAttemptTimeout(
@@ -391,3 +393,13 @@ Deno.test("request and response exports", () => {
   assert(http2.Http2ServerRequest);
   assert(http2.Http2ServerResponse);
 });
+
+Deno.test("internal/http2/util exports", () => {
+  const util = require("internal/http2/util");
+  assert(typeof util.kAuthority === "symbol");
+  assert(typeof util.kSensitiveHeaders === "symbol");
+  assert(typeof util.kSocket === "symbol");
+  assert(typeof util.kProtocol === "symbol");
+  assert(typeof util.kProxySocket === "symbol");
+  assert(typeof util.kRequest === "symbol");
+});