Skip to content

Commit 9c7a50f

Browse files
authored
Pass controller from fetch, and abort SW fetch when it's canceled (#1620)
1 parent 1db9650 commit 9c7a50f

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

docs/index.bs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2982,6 +2982,7 @@ spec: rfc7231; urlPrefix: https://tools.ietf.org/html/rfc7231
29822982

29832983
: Input
29842984
:: |request|, a [=/request=]
2985+
:: |controller|, a [=fetch controller=]
29852986
:: |useHighResPerformanceTimers|, a boolean
29862987
: Output
29872988
:: |response|, a [=/response=]
@@ -3022,15 +3023,16 @@ spec: rfc7231; urlPrefix: https://tools.ietf.org/html/rfc7231
30223023
1. Let |preloadResponseObject| be a new {{Response}} object associated with a new {{Headers}} object whose [=guard=] is "`immutable`".
30233024
1. [=header list/Append=] to |preloadRequestHeaders| a new [=header=] whose [=header/name=] is \`<code>Service-Worker-Navigation-Preload</code>\` and [=header/value=] is |registration|'s [=navigation preload header value=].
30243025
1. Set |preloadRequest|'s [=service-workers mode=] to "`none`".
3025-
1. Run the following substeps [=in parallel=]:
3026-
1. [=Fetch=] |preloadRequest| and let |preloadFetchInstance| be the instance of the [=/fetch=] algorithm.
3026+
1. Let |preloadFetchController| be null.
3027+
1. Run the following substeps [=in parallel=], but [=abort when=] |controller|'s [=fetch controller/state=] is "<code>terminated</code>" or "<code>aborted</code>":
3028+
1. Set |preloadFetchController| to the result of [=Fetch|fetching=] |preloadRequest|.
30273029

30283030
To [=process response=] for |navigationPreloadResponse|, run these substeps:
30293031

30303032
1. If |navigationPreloadResponse|'s [=response/type=] is "`error`", reject |preloadResponse| with a `TypeError` and terminate these substeps.
30313033
1. Associate |preloadResponseObject| with |navigationPreloadResponse|.
30323034
1. Resolve |preloadResponse| with |preloadResponseObject|.
3033-
1. If |fetchInstance| is [=fetch/terminated=], then [=fetch/terminate=] |preloadFetchInstance| with the aborted flag set.
3035+
1. [=If aborted=], then [=fetch controller/abort=] |preloadFetchController|.
30343036
1. Else, resolve |preloadResponse| with undefined.
30353037

30363038
Note: From this point, the [=/service worker client=] starts to <a>use</a> its <a>active service worker</a>'s <a>containing service worker registration</a>.
@@ -3076,7 +3078,7 @@ spec: rfc7231; urlPrefix: https://tools.ietf.org/html/rfc7231
30763078
1. Else, [=ReadableStream/cancel=] |request|'s [=request/body=] with undefined.
30773079
1. If |response| is not null, then set |response|'s [=response/service worker timing info=] to |timingInfo|.
30783080
1. If |e|'s <a>canceled flag</a> is set, set |eventCanceled| to true.
3079-
1. If |fetchInstance| is [=fetch/terminated=], then [=queue a task=] to [=AbortSignal/signal abort=] on |requestObject|'s {{Request/signal}}.
3081+
1. If |controller| [=fetch controller/state=] is "<code>terminated</code>" or "<code>aborted</code>", then [=queue a task=] to [=AbortSignal/signal abort=] on |requestObject|'s {{Request/signal}}.
30803082

30813083
If |task| is discarded, set |handleFetchFailed| to true.
30823084

0 commit comments

Comments
 (0)