Skip to content

fix(http): remove allowH2 from undici Agent — causes fetch failed on Node.js 22+#245

Merged
steipete merged 2 commits intoopenclaw:mainfrom
DColl:main
Feb 13, 2026
Merged

fix(http): remove allowH2 from undici Agent — causes fetch failed on Node.js 22+#245
steipete merged 2 commits intoopenclaw:mainfrom
DColl:main

Conversation

@DColl
Copy link
Contributor

@DColl DColl commented Feb 12, 2026

Remove allowH2 option from global dispatcher

Problem

allowH2: true in the undici Agent dispatcher causes fetch failed
on Node.js 22+ (tested on v25.6.1), making clawhub login completely
broken for all Node.js users.

curl handles the same request fine (HTTP/2 negotiation works correctly
via curl), so the issue is specific to undici's HTTP/2 implementation
on recent Node versions.

Fix

Remove allowH2: true from the Agent config. undici will fall back to
HTTP/1.1 which works correctly.

Testing

  • OS: Ubuntu 24.04, Node.js v25.6.1
  • clawhub login --token <token> now authenticates successfully

Related

Fixes #41
Related: openclaw/openclaw#5366, openclaw/openclaw#6933

Note on the published dist/

The currently published dist/http.js on npm also has a separate
corruption (missing controller/body declarations and a broken
console.log with random whitespace) that doesn't match these sources.
That suggests a build pipeline issue — the npm package may have been
built from a different state than the current source.

Greptile Overview

Greptile Summary

This change updates the CLI HTTP client’s undici global dispatcher (packages/clawdhub/src/http.ts) to stop forcing HTTP/2 (allowH2: true), relying on undici’s default (HTTP/1.1) to avoid fetch failed regressions reported on newer Node.js versions.

The change is scoped to dispatcher configuration and does not alter request/response handling logic in apiRequest* helpers; it only affects the underlying transport negotiation used by fetch in Node runtimes.

Confidence Score: 3/5

  • Reasonably safe, but test configuration likely breaks on Node 22+
  • The code change itself is a minimal deletion in dispatcher config and should resolve the reported Node 22+ undici HTTP/2 issue. However, the repo’s e2e test harness still forces allowH2: true on a global dispatcher, which will likely cause the same fetch failed failures in CI/Node 22+ environments and should be updated in tandem.
  • e2e/clawdhub.e2e.test.ts

Last reviewed commit: f82134c

(2/5) Greptile learns from your feedback when you react with thumbs up/down!

fix/remove-allowH2-undici-node22-compat
@vercel
Copy link
Contributor

vercel bot commented Feb 12, 2026

@DColl is attempting to deploy a commit to the Amantus Machina Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@greptile-apps
Copy link

greptile-apps bot commented Feb 12, 2026

Additional Comments (1)

e2e/clawdhub.e2e.test.ts
E2E tests still enable H2

This PR removes allowH2: true from the CLI’s global dispatcher because it breaks fetch on Node.js 22+, but e2e/clawdhub.e2e.test.ts still sets a global undici Agent with allowH2: true. On Node.js 22+ this will reproduce the same fetch failed behavior during e2e runs, making the test suite fail in the environment the PR targets.

Also appears as the removed option in packages/clawdhub/src/http.ts.

Prompt To Fix With AI
This is a comment left during a code review.
Path: e2e/clawdhub.e2e.test.ts
Line: 20:25

Comment:
**E2E tests still enable H2**

This PR removes `allowH2: true` from the CLI’s global dispatcher because it breaks `fetch` on Node.js 22+, but `e2e/clawdhub.e2e.test.ts` still sets a global undici `Agent` with `allowH2: true`. On Node.js 22+ this will reproduce the same `fetch failed` behavior during e2e runs, making the test suite fail in the environment the PR targets.

Also appears as the removed option in `packages/clawdhub/src/http.ts`.


How can I resolve this? If you propose a fix, please make it concise.

Copy link
Contributor

@vercel vercel bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional Suggestion:

The e2e test file still uses allowH2: true in undici Agent config, which causes fetch failed errors on Node.js 22+ - the same issue the PR fixes in production code.

Fix on Vercel

@steipete steipete merged commit 2e492a5 into openclaw:main Feb 13, 2026
1 of 2 checks passed
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.

CLI login returns Unauthorized despite successful browser auth

2 participants