Files
Peter Steinberger b6306da1a9 fix(web-fetch): honor cancellation before caching or returning provider results (#131585)
* fix(web-fetch): honor cancellation in the provider fallback

Pass the optional AbortSignal execution context through fetch providers and the Firecrawl adapter. Reject late provider results before wrapping or caching, recheck after asynchronous payload construction, and preserve cancellation through HTML fallback recovery.

* fix(web-fetch): finalize cancellation before caching results

Reject pre-aborted cache hits and preserve cancellation when a provider or guard cleanup fails after abort. Centralize direct and provider cache publication after the complete fetch lifecycle so cancellation during release cannot leave a successful entry.

Extend all four fallback cancellation cases with late provider failures, cover direct/provider pre-aborted cache hits and guard-release races, and document the completed cancellation boundary.

* fix(web-fetch): scope the post-cancellation guard to provider failures

The cancellation guard sat in runWebFetch's catch, so a fetch that rejected
*because of* the abort had its original error replaced by signal.reason. That
discarded the transport's own failure detail and changed an existing contract:
web-tools.fetch.test.ts asserts the tool surfaces the aborted fetch's error.

fetchWebPayload already rethrows the original error when the signal aborted, so
the outer guard only ever needed to cover the provider-fallback path, where a
late failure should surface the caller's abort reason rather than an error from
work the caller had already abandoned. Move it there and drop the outer catch.

* docs(web-fetch): state cancellation forwarding and error preservation accurately

Two wording corrections from deep review. The inline comment claimed an
abort-caused fetch rejection "already carries the caller's reason", which the
regression test deliberately shows is not always true; the code preserves the
right object regardless. The docs implied cancellation stops provider work,
when core only forwards the signal and rejects late results.
2026-08-28 21:06:18 -07:00
..
…
…
…
…