Bug 246069
| Summary: | Use AbortSignal.reason in Fetch code | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | nidhijaju |
| Component: | DOM | Assignee: | Nobody <webkit-unassigned> |
| Status: | NEW | ||
| Severity: | Normal | CC: | achristensen, frederick888, webkit-bug-importer, youennf, ysuzuki |
| Priority: | P2 | Keywords: | InRadar |
| Version: | WebKit Nightly Build | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
nidhijaju
In https://github.com/whatwg/fetch/pull/1343, the Http-network fetch and fetch() method have been updated to use AbortSignal's abort reason (or a serialized version of it) when erroring streams and aborting the fetch() call, rather than unconditionally using an AbortError. This change also includes using the abort reason to abort the fetch controller.
There are some related changes in the Service Worker spec in https://github.com/w3c/ServiceWorker/pull/1655. When a service worker intercepts a fetch request, the signal's abort reason is passed to the service worker to abort the fetch controller and signal abort in the Handle Fetch algorithm.
The same change needs to be made to the Safari implementation.
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Radar WebKit Bug Importer
<rdar://problem/101068136>
Frederick Zhang
I'm using Safari 18.2 and it still has this issue.
Interestingly, if a signal is already aborted before fetch(), there seems to be some early-return logic and it actually copies the reason in this case:
let c = new AbortController()
c.abort('Foo')
fetch('https://example.com', { signal: c.signal }).catch(e => console.debug({e, name: e.name, message: e.message})).then(res => console.debug(res))
// output: {e: "Foo", name: undefined, message: undefined}
let s = AbortSignal.timeout(0)
fetch('https://example.com', { signal: s }).catch(e => console.debug({e, name: e.name, message: e.message})).then(res => console.debug(res))
// output: {e: TimeoutError: The operation timed out., name: "TimeoutError", message: "The operation timed out."}