whatwg / fetch

Fetch Standard

Home Page:https://fetch.spec.whatwg.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Service worker "handle fetch" seems to assume it's called in parallel

domenic opened this issue · comments

What is the issue with the Fetch Standard?

Some time ago we refactored fetch to be callable from everywhere, including the main thread, with callbacks to signal the result.

In this world, fetch calls "handle fetch" without going in parallel. It's assumed that "handle fetch" synchronously returns a response.

Handle fetch does synchronously return a response. But it does so with various "Wait" calls, e.g.

Wait for task to have executed or for handleFetchFailed to be true.

In general it's very unclear to me exactly how Handle Fetch is anticipating being called, actually... sometimes it explicitly goes in parallel itself. Sometimes it manipulates main-thread objects like promises. Sometimes it queues tasks, as if it was already in parallel. But, probably it's best to assume it's supposed to be executing in parallel.

Fetch itself is always in parallel at that point, no? Per step 11 of https://fetch.spec.whatwg.org/#concept-main-fetch. (To be clear, no disagreement that this can all be improved.)

Yep, my eyes totally glazed over that step; sorry!