openclaw - ✅(Solved) Fix web_fetch/web_search fails with 'fetch failed' due to undici 8.0.0 dispatcher bug [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#61738Fetched 2026-04-08 02:55:10
View on GitHub
Comments
0
Participants
1
Timeline
14
Reactions
0
Participants
Timeline (top)
referenced ×11cross-referenced ×2closed ×1

Error Message

[tools] web_fetch failed: fetch failed raw_params={"url":"https://api.exchangerate-api.com/v4/latest/CNY","maxChars":500}
[tools] web_search failed: fetch failed raw_params={"query":"f1","count":3}

Root Cause

When explicitly passing a dispatcher to fetch(), undici 8.0.0 fails with "fetch failed" for HTTPS connections. This affects the SSRF guard's PinnedDispatcher used in web_fetch and web_search.

Reproduction:

// Works - no dispatcher
await fetch('https://www.google.com/'); // OK

// Fails - with dispatcher
const dispatcher = new Agent({});
await fetch('https://www.google.com/', { dispatcher }); // "fetch failed"

Fix Action

Fix / Workaround

web_fetch and web_search tools fail with "fetch failed" error when using the SSRF guard's PinnedDispatcher, even though network connectivity is working (curl and Node.js native fetch work fine).

When explicitly passing a dispatcher to fetch(), undici 8.0.0 fails with "fetch failed" for HTTPS connections. This affects the SSRF guard's PinnedDispatcher used in web_fetch and web_search.

Reproduction:

// Works - no dispatcher
await fetch('https://www.google.com/'); // OK

PR fix notes

PR #61777: fix(ssrf): disable HTTP/2 for pinned dispatchers (undici 8.0)

Description (problem / solution / changelog)

Summary

Fixes TypeError: fetch failed when using web_fetch / web_search tools after upgrading to undici 8.0.0.

undici 8.0 enables HTTP/2 by default. The SSRF-guard's PinnedDispatcher performs a custom DNS lookup and pins the resolved IP, but HTTP/2's connection model is incompatible with this pinning strategy, causing all fetches through the dispatcher to fail.

This PR sets allowH2: false on pinned dispatchers to restore HTTP/1.1 behavior, keeping the SSRF DNS-pinning guard functional.

Closes #61738

Changes

  • src/plugins/contracts/runtime-seams.ts — set allowH2: false on PinnedDispatcher options
  • src/plugins/contracts/runtime-seams.contract.test.ts — add test verifying H2 is disabled
  • extensions/discord/src/proxy-request-client.ts — fix pre-existing TS type error from carbon beta bump (unrelated to SSRF, but unblocks CI for all open PRs)

Testing

  • Unit test added for allowH2: false on pinned dispatcher
  • All pre-existing contract tests pass
  • TypeScript build error from carbon beta fixed

Changed files

  • CHANGELOG.md (modified, +1/-1)
  • extensions/discord/src/monitor/monitor.test.ts (modified, +10/-4)
  • src/agents/bash-tools.exec.approval-id.test.ts (modified, +0/-10)
  • src/agents/bash-tools.exec.background-abort.test.ts (modified, +4/-2)
  • src/agents/bash-tools.process.poll-timeout.test.ts (modified, +3/-2)
  • src/agents/model-auth.profiles.test.ts (modified, +1/-0)
  • src/agents/model-auth.test.ts (modified, +1/-0)
  • src/agents/model-selection.test.ts (modified, +4/-0)
  • src/agents/model-selection.ts (modified, +4/-0)
  • src/agents/pi-embedded-runner/model.forward-compat.errors-and-overrides.test.ts (modified, +1/-1)
  • src/agents/pi-embedded-runner/run/attempt.spawn-workspace.test-support.ts (modified, +4/-0)
  • src/agents/provider-request-config.test.ts (modified, +1/-1)
  • src/agents/tools/music-generate-tool.actions.ts (modified, +4/-2)
  • src/agents/tools/video-generate-tool.actions.ts (modified, +4/-2)
  • src/gateway/client.ts (modified, +4/-5)
  • src/hooks/bundled/session-memory/transcript.ts (modified, +1/-0)
  • src/infra/net/fetch-guard.ssrf.test.ts (modified, +14/-1)
  • src/infra/net/fetch-guard.ts (modified, +12/-8)
  • src/infra/net/ssrf.dispatcher.test.ts (modified, +4/-0)
  • src/infra/net/ssrf.ts (modified, +9/-6)
  • src/infra/net/undici-runtime.ts (modified, +49/-0)
  • src/shared/text/model-special-tokens.ts (modified, +20/-7)

Code Example

// Works - no dispatcher
await fetch('https://www.google.com/'); // OK

// Fails - with dispatcher
const dispatcher = new Agent({});
await fetch('https://www.google.com/', { dispatcher }); // "fetch failed"

---

[tools] web_fetch failed: fetch failed raw_params={"url":"https://api.exchangerate-api.com/v4/latest/CNY","maxChars":500}
[tools] web_search failed: fetch failed raw_params={"query":"f1","count":3}
RAW_BUFFERClick to expand / collapse

Problem Description

web_fetch and web_search tools fail with "fetch failed" error when using the SSRF guard's PinnedDispatcher, even though network connectivity is working (curl and Node.js native fetch work fine).

Environment

  • openclaw version: 2026.4.4
  • Node.js: 22.22.2
  • undici: 8.0.0
  • macOS: Darwin 25.2.0

Root Cause

When explicitly passing a dispatcher to fetch(), undici 8.0.0 fails with "fetch failed" for HTTPS connections. This affects the SSRF guard's PinnedDispatcher used in web_fetch and web_search.

Reproduction:

// Works - no dispatcher
await fetch('https://www.google.com/'); // OK

// Fails - with dispatcher
const dispatcher = new Agent({});
await fetch('https://www.google.com/', { dispatcher }); // "fetch failed"

Expected Behavior

web_fetch and web_search should successfully fetch URLs when network connectivity is available.

Logs

[tools] web_fetch failed: fetch failed raw_params={"url":"https://api.exchangerate-api.com/v4/latest/CNY","maxChars":500}
[tools] web_search failed: fetch failed raw_params={"query":"f1","count":3}

Additional Context

  • curl works fine
  • Node.js native fetch (without dispatcher) works fine
  • searxng container accessed via curl works fine
  • The issue is specifically with undici's dispatcher when passed explicitly to fetch

Suggested Fix

Consider temporarily working around undici 8.0.0 dispatcher bug by not passing explicit dispatcher to fetch, or downgrade undici to a version that doesn't have this regression.

extent analysis

TL;DR

Downgrade undici to a version prior to 8.0.0 to avoid the dispatcher bug affecting HTTPS connections.

Guidance

  • Verify that the issue is indeed caused by the undici dispatcher bug by testing with a version prior to 8.0.0.
  • Temporarily workaround the issue by not passing an explicit dispatcher to fetch() in web_fetch and web_search tools.
  • Consider updating the SSRF guard's PinnedDispatcher to handle the undici dispatcher bug or to use a different dispatcher implementation.
  • Test network connectivity using curl and Node.js native fetch to ensure the issue is specific to undici's dispatcher.

Example

// Temporary workaround - do not pass dispatcher
await fetch('https://www.google.com/'); // Should work

// Alternative - use a different dispatcher or update PinnedDispatcher
// const dispatcher = new AlternativeDispatcher({});
// await fetch('https://www.google.com/', { dispatcher });

Notes

The suggested fix assumes that downgrading undici or not passing an explicit dispatcher does not introduce other compatibility issues. Further testing is recommended to ensure the workaround does not affect other parts of the application.

Recommendation

Apply workaround: Downgrade undici to a version prior to 8.0.0, as it is a more straightforward solution that directly addresses the identified bug, allowing web_fetch and web_search to function correctly until a permanent fix is available.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING