Skip to content

fix(web-fetch): release unread responses after provider fallback - #115759

Merged
steipete merged 1 commit into
mainfrom
codex/s16-web-fetch-fallback-lifecycle
Jul 29, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/s16-web-fetch-fallback-lifecycle

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Related: #111332

What Problem This Solves

Fixes an issue where users relying on a configured web-fetch provider fallback could leak upstream HTTP connections whenever a direct fetch returned an unread error response. A successful fallback returned to the agent while the original response kept streaming; a provider failure leaked the same response while propagating the error.

Why This Change Was Made

Cancel an upstream response exactly once in the existing guarded-fetch cleanup when its body remains unread. Start cancellation before releasing the network guard without awaiting it, so a noncompliant never-settling stream cannot block a successful fallback. Already-consumed HTML/readability responses, provider selection and cache behavior, original provider errors, and private-network/SSRF policy remain unchanged.

This is a trusted-main, smaller and more complete follow-up to @nocodet888-arch's original #111332. The original contributor is credited as a commit co-author.

User Impact

Provider fallback no longer leaves HTTP streams or sockets open, including when the provider itself fails. Long-running agents retain bounded HTTP resources without weakening web-fetch SSRF protection or introducing configuration.

Evidence

  • Reproduced all four regressions against trusted current main before the production fix: successful fallback leaked its upstream stream; throwing fallback leaked its stream; non-settling cancellation was not started; and a real production guarded node:http loopback response kept its socket open.
  • Red-first Testbox: 4 failed / 5 existing passed.
  • After the five-line owner-boundary fix: 184 / 184 tests passed across 10 focused web-fetch, provider, real guarded HTTP, SSRF, visibility, Cloudflare markdown, readability, response output, network guard, and shared-response test files.
  • Full pnpm check:changed passed on the exact final patch, including formatting, core/core-test typechecks, lint, dead-export, SDK/boundary, and repository guards.
  • Independent gpt-5.6-sol xhigh autoreview: clean, 0.98 confidence.
  • Real HTTP evidence exercises the actual guarded loopback server and observes the abandoned response socket close; private-network access is enabled only within that test, while all 11 production SSRF regressions remain green.
  • Remote proof: blacksmith-testbox, final command exit 0; lease stopped after proof.
  • AI-assisted; reviewed against Undici's documented requirement to consume or cancel response bodies.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Jul 29, 2026
@steipete
steipete force-pushed the codex/s16-web-fetch-fallback-lifecycle branch from 095f998 to 232b6ac Compare July 29, 2026 08:36
@steipete
steipete merged commit 90ab06b into main Jul 29, 2026
189 of 191 checks passed
@steipete
steipete deleted the codex/s16-web-fetch-fallback-lifecycle branch July 29, 2026 09:37
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

pull Bot pushed a commit to yann0001/openclaw that referenced this pull request Jul 29, 2026
* origin/main:
  fix(gateway): keep Responses replacement streams consistent (openclaw#115799)
  fix(gateway): hosted setup exits no longer stop the gateway (openclaw#115671)
  fix(cron): protect sessions throughout model preparation (openclaw#115804)
  fix(ui): preserve model names alongside aliases (openclaw#115789)
  fix(qa): prepare shared Slack live flows
  fix(ui): stabilize memory engine selection (openclaw#115750)
  fix(web-fetch): release abandoned fallback response bodies (openclaw#115759)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 30, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 30, 2026
* origin/main:
  fix(gateway): keep Responses replacement streams consistent (openclaw#115799)
  fix(gateway): hosted setup exits no longer stop the gateway (openclaw#115671)
  fix(cron): protect sessions throughout model preparation (openclaw#115804)
  fix(ui): preserve model names alongside aliases (openclaw#115789)
  fix(qa): prepare shared Slack live flows
  fix(ui): stabilize memory engine selection (openclaw#115750)
  fix(web-fetch): release abandoned fallback response bodies (openclaw#115759)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant