From d5f0d8576a5d724853b18582b14922e8b29975e0 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Thu, 30 Sep 2021 13:15:34 +0300 Subject: [PATCH] Attach timing info and URL to network errors Set an opaque timing info and the original request URL to the error resposne, and call the processResponseDone callback to allow the caller to report it. This should already be the case for reporting network errors in the fetch() API. Closes #1215 Set network error timing info and URL at the start of fetch finale Rearrange fetch finale step Make sure we don't report network errors twice Use queues for synchronization --- fetch.bs | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 52 insertions(+), 5 deletions(-) diff --git a/fetch.bs b/fetch.bs index 92c09c30b..2ceb32ca6 100644 --- a/fetch.bs +++ b/fetch.bs @@ -203,6 +203,8 @@ lt="authentication entry">authentication entries (for HTTP authentication).
Null, a global object, or a parallel queue.
cross-origin isolated capability (default false) +
ready for clients (default false). +
network read complete (default false).
A boolean.
timing info @@ -4140,6 +4142,27 @@ steps: response response, run these steps:
    +
  1. +

    If response is a network error, then: + +

      +
    1. +

      Set response's URL list to « fetchParams's + request's URL list ≫. + +

      This is needed as after cloning fetchParams's + request's URL list earlier, response + might have been set to a network error.

      +
    2. + +
    3. Set response's timing info to the result of + creating an opaque timing info for fetchParams's + timing info.

    4. + +
    5. Set fetchParams's network read complete to true. +

    +
  2. +
  3. If fetchParams's process response is non-null, then queue a fetch task to run fetchParams's process response given response, with fetchParams's @@ -4165,19 +4188,43 @@ steps: processBody, processBodyError, and fetchParams's task destination.

+ + +
  • +

    Queue a fetch task to run the following steps with fetchParams's + task destination:

    + +
      +
    1. Set fetchParams's ready for clients to true.

    2. + +
    3. Finalize response given fetchParams and response.

    4. +
    + + +

    To fetch network finale given a fetch params fetchParams +and a response response, queue a fetch task +with to run the following steps with fetchParams's +task destination:

    + +
      +
    1. Set fetchParams's network read complete.

    2. + +
    3. Finalize response given fetchParams and response.

    To finalize response given a fetch params fetchParams and a response response, run these steps:

      +
    1. IffetchParams's ready for clients is false or + fetchParams's network read complete is false, return.

    2. +
    3. Set fetchParams's request's done flag.

    4. If fetchParams's process response done is not null, - then queue a fetch task to run fetchParams's - process response done given response, - with fetchParams's task destination. + then run fetchParams's process response done with + response.

    To finalize and report timing given a response @@ -5526,7 +5573,7 @@ optional boolean forceNewConnection (default false), run these steps:

  • Otherwise, if the bytes transmission for response's message body is done normally and stream is readable, then - close stream, finalize response for + close stream, run fetch network finale for fetchParams and response, and abort these in-parallel steps. @@ -5535,7 +5582,7 @@ optional boolean forceNewConnection (default false), run these steps:

    If aborted, then:

      -
    1. Finalize response for fetchParams and response. +
    2. Run fetch network finale for fetchParams and response.
    3. Let aborted be the termination's aborted flag.