Re: [whatwg/fetch] Attach timing info and URL to network errors, and report for fetch API (#1311)

@noamr commented on this pull request.

Revised in the spirit of the comments.

> @@ -4200,6 +4200,60 @@ steps:
 <a for=/>response</a> <var>response</var>, run these steps:
 
 <ol>
+ <li>
+  <p>If <var>response</var> is a <a>network error</a>, then:
+
+  <ol>
+   <li>
+    <p>Set <var>response</var>'s <a for=response>URL list</a> to « <var>fetchParams</var>'s
+    <a for="fetch params">request</a>'s <a for=request>URL list</a> ≫.

Damn, I thought I've fixed this 10 times.

> +   <a for="fetch params">process response done</a> given <var>response</var> with
+   <var>fetchParams</var>'s <a for="fetch params">task destination</a>.
+  </ol>
+ </li>
+
+ <li>
+  <p>If <var>hasReadableStream</var> is true, then:
+
+  <ol>
+   <li><p>Let <var>transformStream</var> be a new a {{TransformStream}}.
+
+   <li><p>Let <var>identityTransformAlgorithm</var> be an algorithm which, given <var>chunk</var>,
+   <a for=TransformStream lt=enqueue>enqueues</a> <var>chunk</var> in <var>transformStream</var>.
+
+   <li><p><a for=TransformStream lt="setting up">Set up</a> <var>transformStream</var> with
+   <var>identityTransformAlgorithm</var> and <var>processResponseDone</var>.

OK

> @@ -4210,12 +4264,23 @@ steps:
   then:
 
   <ol>
+   <li>
+    <p>Let <var>processEndOfBody</var> given <var>nullBytesOrFailure</var> be the following
+    steps:
+
+    <ol>
+     <li><p>Run <var>processResponseDone</var>.

I was trying to fiddle with the order of things, but will revise to make it cleaner.

> +    <p>Set <var>response</var>'s <a for=response>URL list</a> to « <var>fetchParams</var>'s
+    <a for="fetch params">request</a>'s <a for=request>URL list</a> ≫.
+
+    <p class=note>This is needed as after <a for=list>cloning</a> <var>fetchParams</var>'s
+    <a for="fetch params">request</a>'s <a for=request>URL list</a> earlier, <var>response</var>
+    might have been set to a <a>network error</a>.</p>
+   </li>
+
+   <li><p>Set <var>response</var>'s <a for=response>timing info</a> to the result of
+   <a>creating an opaque timing info</a> for <var>fetchParams</var>'s
+   <a for="fetch params">timing info</a>.</p></li>
+  </ol>
+ </li>
+
+ <li><p>Let <var>hasReadableStream</var> be true if <var>response</var>'s <a for=response>body</a>
+ is not null and is <a for=ReadableStream>readable</a>; otherwise false.

OK

>  
- <li><p>If <var>fetchParams</var>'s <a for="fetch params">process response done</a> is not null,
- then <a>queue a fetch task</a> to run <var>fetchParams</var>'s
- <a for="fetch params">process response done</a> given <var>response</var>,
- with <var>fetchParams</var>'s <a for="fetch params">task destination</a>.
+  <li><p>If <var>hasReadableStream</var> is false, then run <var>processResponseDone</var>.</p></li>

Right

> + <li>
+  <p>If <var>hasReadableStream</var> is true, then:
+
+  <ol>
+   <li><p>Let <var>transformStream</var> be a new a {{TransformStream}}.
+
+   <li><p>Let <var>identityTransformAlgorithm</var> be an algorithm which, given <var>chunk</var>,
+   <a for=TransformStream lt=enqueue>enqueues</a> <var>chunk</var> in <var>transformStream</var>.
+
+   <li><p><a for=TransformStream lt="setting up">Set up</a> <var>transformStream</var> with
+   <var>identityTransformAlgorithm</var> and <var>processResponseDone</var>.
+
+   <li><p>Set <var>response</var>'s <a for=response>body</a> to the result of
+   <a for=ReadableStream lt="piping through">piping</a> <var>response</var>'s
+   <a for=response>body</a> through <var>transformStream</var>.
+  </ol>

Done

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/pull/1311#pullrequestreview-822612836

Received on Friday, 3 December 2021 13:09:12 UTC