-
Notifications
You must be signed in to change notification settings - Fork 336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add abort reason to abort fetch #1343
Changes from 5 commits
a18ee76
6e0fe40
4a06427
eb499b4
c0833a5
55d734e
4df5ef6
75d4bad
b6ddcaa
ba73b86
ddd1628
62edcfe
14dac0d
8194bf6
f660a6e
2255611
f44930c
122bae5
cc54cd6
647f4f5
e5b0236
1b86ddc
b6a779d
6a0f4aa
63ad081
f86437e
38ea956
662fe10
70ade67
a29fd77
01a87c0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7428,12 +7428,15 @@ method steps are: | |
|
||
<li><p>Let <var>request</var> be <var>requestObject</var>'s <a for=Request>request</a>. | ||
|
||
<li><p>Let <var>error</var> be <var>requestObject</var>'s <a for=Request>signal</a>'s | ||
<a for=AbortSignal>abort reason</a>. | ||
|
||
<li> | ||
<p>If <var>requestObject</var>'s <a for=Request>signal</a>'s <a for=AbortSignal>aborted flag</a> | ||
is set, then: | ||
<p>If <var>requestObject</var>'s <a for=Request>signal</a> is <a for=AbortSignal>aborted</a>, | ||
then: | ||
|
||
<ol> | ||
<li><p><a>Abort fetch</a> with <var>p</var>, <var>request</var>, and null. | ||
<li><p><a>Abort fetch</a> with <var>p</var>, <var>request</var>, null, and <var>error</var>. | ||
|
||
<li><p>Return <var>p</var>. | ||
</ol> | ||
|
@@ -7461,7 +7464,8 @@ method steps are: | |
<ol> | ||
<li><p>Set <var>locallyAborted</var> to true. | ||
|
||
<li><p><a>Abort fetch</a> with <var>p</var>, <var>request</var>, and <var>responseObject</var>. | ||
<li><p><a>Abort fetch</a> with <var>p</var>, <var>request</var>, <var>responseObject</var>, and | ||
<var>error</var>. | ||
|
||
<li><p><a lt=terminated for=fetch>Terminate</a> the ongoing fetch with the aborted flag set. | ||
</ol> | ||
|
@@ -7479,8 +7483,8 @@ method steps are: | |
<li><p>If <var>locallyAborted</var> is true, terminate these substeps. | ||
|
||
<li><p>If <var>response</var>'s <a for=response>aborted flag</a> is set, then <a>abort fetch</a> | ||
with <var>p</var>, <var>request</var>, and <var>responseObject</var>, and terminate these | ||
substeps. | ||
with <var>p</var>, <var>request</var>, <var>responseObject</var>, and <var>error</var>, and | ||
nidhijaju marked this conversation as resolved.
Show resolved
Hide resolved
|
||
terminate these substeps. | ||
|
||
<li><p>If <var>response</var> is a <a>network error</a>, then <a for=/>reject</a> <var>p</var> | ||
with a {{TypeError}} and terminate these substeps. | ||
|
@@ -7494,11 +7498,12 @@ method steps are: | |
<li><p>Return <var>p</var>. | ||
</ol> | ||
|
||
<p>To <dfn>abort fetch</dfn> with a <var>promise</var>, <var>request</var>, and | ||
<var>responseObject</var>, run these steps: | ||
<p>To <dfn>abort fetch</dfn> with a <var>promise</var>, <var>request</var>, | ||
nidhijaju marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<var>responseObject</var>, and an optional <var>error</var>, run these steps: | ||
|
||
<ol> | ||
<li><p>Let <var>error</var> be an "<code><a exception>AbortError</a></code>" {{DOMException}}. | ||
<li><p>If <var>error</var> is not given, let <var>error</var> be an | ||
"<code><a exception>AbortError</a></code>" {{DOMException}}. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. error is always given I think, but it can be undefined. I think the text here and in Streams suggest we should have this primitive in DOM. Something like
What do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An alternative might be to pass the signal on and then we define
That might make it a bit easier to use. I.e., callers can say "throw signal's error". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But can it ever be undefined? It seems both |
||
|
||
<li> | ||
<p><a for=/>Reject</a> <var>promise</var> with <var>error</var>. | ||
|
@@ -8079,6 +8084,7 @@ Moritz Kneilmann, | |
Ms2ger, | ||
Nico Schlömer, | ||
Nicolás Peña Moreno, | ||
Nidhi Jaju, | ||
Nikhil Marathe, | ||
Nikki Bee, | ||
Nikunj Mehta, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the modifications to fetch() work as written. Remember, they are running synchronously, while the fetch proceeds in parallel. So consider code like this:
In your inserted step 4 here, you set error to a clone of
controller.signal.reason
. Butcontroller.signal.reason
is undefined, becausecontroller.abort()
is not called yet. So when we get down to step 14+15, we will serialize undefined and store it, which is pretty useless.What happens if we just remove steps 14+15?