Skip to content

Make the built-in fetch use HTTP/1.1 in every command (RA-020) - #89

Open
JOsacky wants to merge 1 commit into
mainfrom
reliability/ra-020-http1-fetch
Open

JOsacky wants to merge 1 commit into
mainfrom
reliability/ra-020-http1-fetch

Conversation

@JOsacky

@JOsacky JOsacky commented Nov 16, 2026

Copy link
Copy Markdown
Member

What

Every skillhook process started through the CLI (the serve daemon included) now makes Node's built-in fetch use HTTP/1.1, as it did on Node 22:

  • src/http1.ts: useHttp1ForFetch() installs setGlobalDispatcher(new Agent({ allowH2: false })) from the undici package, which is how Node documents configuring the built-in fetch. If Node already installed its own proxy-aware dispatcher for NODE_USE_ENV_PROXY, the function leaves it in place.
  • src/cli.ts calls it before main(), so all commands do it before any request. The library entry (src/index.ts) is unchanged and does not touch its host's dispatcher.
  • undici@^7.30.2 is a new runtime dependency (lockfile: 7.30.2). Its engines.node is >=20.18.1, which our >=22 satisfies, and it has no dependencies. undici 8.x needs >=22.19.0, so I did not use it. It sets both global dispatcher symbols (undici.globalDispatcher.1 and .2), so Node 22's bundled undici 6 and Node 26's bundled undici 8 both read it.
  • Repo rule change: AGENTS.md ("Runtime dependencies stay at three") and CONTRIBUTING.md now name undici as the fourth runtime dependency. Please confirm you are OK with this.
  • CHANGELOG ## Unreleased entry. No version bump.

Why (RA-020)

The main skillhook daemon ran away twice, on 2026-11-10 and 2026-11-13, inside Node's native HTTP/2 write path (Http2Session::SendPendingData → nghttp2_session_mem_send). It grew to about 23M resident pages and macOS jetsam killed it, which stopped all agent work for about 30 minutes each time. The operator machine runs Node 26.13.0, whose bundled undici (8.12.2) negotiates h2 via ALPN in the built-in fetch. Node 22 (undici 6.x) uses HTTP/1.1. Neither skillhook nor its dependencies import node:http2, so the HTTP/2 sessions come from the built-in fetch. Node creates the bundled global dispatcher lazily on the first fetch, so the only way to configure it before the first request is a dispatcher from the undici package.

How it was tested

  • New src/http1.test.ts. It creates a throwaway self-signed certificate at test time with openssl in a temp dir, deleted afterwards. Nothing is committed, and the test is skipped if openssl is missing. It then starts a local http2.createSecureServer({ allowHTTP1: true }) on 127.0.0.1 that responds with req.httpVersion, and checks three things:

    1. A TLS client that offers h2, http/1.1 gets h2 from the server.
    2. Control: the built-in fetch gets 2.0 when its dispatcher allows h2.
    3. After useHttp1ForFetch(), the built-in fetch gets 1.1.

    The CA is passed only through the test's dispatcher connect: { ca }. NODE_TLS_REJECT_UNAUTHORIZED is not used. All traffic stays local.

  • Locally on Node 26.13.0: pnpm run typecheck, pnpm test (64 files, 536 tests), pnpm run build, pnpm run schema --check and pnpm run release --check all pass. node dist/cli.js --version works.

  • Locally on Node 22.23.4: src/http1.test.ts passes (3/3) and dist/cli.js --version works.

  • CI covers Node 22, 24 and 26.

How to revert

Revert this squash commit. That removes the hook, the test and the dependency, and restores the docs. Nothing on disk or in config changes. If only the runtime behaviour has to go, deleting the useHttp1ForFetch() call in src/cli.ts brings back the bundled default (HTTP/2 on Node 26).

After merge

The fix only takes effect on the operator machine once a release containing it is published and the daemon restarts onto it. This PR does not release or restart anything.

🤖 Generated with Claude Code

Node 26's bundled undici negotiates HTTP/2 via ALPN, so every HTTPS fetch
the daemon made ran over a native HTTP/2 session. On 2026-11-10 and
2026-11-13 the daemon spun inside Http2Session::SendPendingData until
macOS jetsam killed it (about 30 minutes without jobs each time).

src/cli.ts now installs a global dispatcher from the undici package with
allowH2: false before any command runs (the way Node documents
configuring fetch), matching Node 22 behaviour. undici 7.30.2 (engines
>=20.18.1, no dependencies) is the fourth runtime dependency; AGENTS.md
and CONTRIBUTING.md say so. A dispatcher Node made for
NODE_USE_ENV_PROXY is kept.

The new test starts a local TLS server offering h2 and http/1.1 with a
throwaway self-signed certificate, checks it negotiates h2 when offered,
and that the built-in fetch gets HTTP/1.1 after the hook.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant