Join GitHub today
Handing fetch termination #1178
I agree, but this feels like a special case since fetch called me, I didn't call fetch.
In the fetch spec I've tried to keep termination handling as close to the leaf end as I can. HTTP fetch doesn't have a "If terminates" break clause around the call to service workers, so it feels "handle fetch" should be handling the termination.
Alternatively, I could add a break clause the call to "handle fetch" in "main fetch". Then, in "handle fetch" I can somehow "handle response" for the outer fetch, and see if its abort flag is set. But this will be really messy, as the fetch spec is waiting for a response from the service worker spec, but the service worker spec is also waiting for a response from the fetch spec. I'd also end up looping the service worker response back into the service worker spec via the fetch spec, and I'd need to ignore that somehow.
I've updated the PR a little, but it seems to express the behaviour pretty clearly. It's a bit hand-wavey around getting an instance of the fetch, but I think that's part of whatwg/fetch#536 (comment).