From 64255fe42ae66cf53b32f6ad1e9dc0b90a8a6cdd Mon Sep 17 00:00:00 2001 From: "Vincent (Wen Yu) Ge" Date: Thu, 3 Sep 2026 13:06:54 -0400 Subject: [PATCH] fix: keep fetch on HTTP/1.1 so Node 26 does not exit the wizard mid-run Node 26 bundles undici 8, which turns HTTP/2 on for fetch. The MCP SDK aborts its GET event stream on close() before the response headers arrive, node:http2 creates an orphan ClientHttp2Stream for the server's late HEADERS, and undici's idle-session reaper destroys the socket 4s later with an InformationalError that the orphan re-emits with no listener. posthog-node's exception autocapture exits the process on it. Force HTTP/1.1 on the global dispatcher, the same call pi's CLI makes. Closes #1198 Co-Authored-By: Claude Fable 5.1 --- bin.ts | 14 ++++++++++++++ package.json | 1 + pnpm-lock.yaml | 3 +++ 3 files changed, 18 insertions(+) diff --git a/bin.ts b/bin.ts index f4bb1bd58..2f0b20363 100644 --- a/bin.ts +++ b/bin.ts @@ -1,5 +1,6 @@ #!/usr/bin/env node import { satisfies } from 'semver'; +import { Agent, setGlobalDispatcher } from 'undici'; import { ErrorCodes } from './src/lib/errors/codes.js'; import { emitWizardError } from './src/lib/errors/emit.js'; @@ -9,6 +10,19 @@ import { emitWizardError } from './src/lib/errors/emit.js'; // TypeError on Node < 22.10). const NODE_VERSION_RANGE = '>=22.22.0'; +/* + * TODO(#1198): remove when fetch over HTTP/2 is safe on Node 26. Remove when all + * of these are true: + * - nodejs/node no longer creates an orphan ClientHttp2Stream when a client + * session gets HEADERS for a stream id it already reset. Repro: abort a fetch + * before its response headers, then idle 4s on Node 26. Fixed when the + * process survives. + * - modelcontextprotocol/typescript-sdk#2526 is closed. + * - pi-coding-agent's CLI drops `allowH2: false` from its http-dispatcher. + * Same workaround as pi's CLI and typescript-sdk#2526: HTTP/1.1 only. + */ +setGlobalDispatcher(new Agent({ allowH2: false })); + // Have to run this above the other imports because they are importing clack that // has the problematic imports. if (!satisfies(process.version, NODE_VERSION_RANGE)) { diff --git a/package.json b/package.json index cdb312cf1..4ec58c5e2 100644 --- a/package.json +++ b/package.json @@ -60,6 +60,7 @@ "recast": "^0.23.3", "semver": "^7.5.3", "typebox": "1.1.38", + "undici": "8.5.0", "uuid": "^11.1.0", "xcode": "3.0.1", "xml-js": "^1.6.11", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e0fab1552..7c2d2ae30 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -92,6 +92,9 @@ importers: typebox: specifier: 1.1.38 version: 1.1.38 + undici: + specifier: 8.5.0 + version: 8.5.0 uuid: specifier: ^11.1.0 version: 11.1.0