-
Notifications
You must be signed in to change notification settings - Fork 337
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
Attach timing info and URL to network errors, and report for fetch API #1311
Conversation
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.
Generally this seems to be heading in the right direction. Thanks for tackling this!
I haven't checked in detail whether this overlooks any network error creation.
I think the creation algorithm needs some slight tweaks.
And I think we want to change things such that processResponseDone also runs in the event of a network error.
f090669
to
7694a3f
Compare
Looking at this again I think I missed something initially and this could be a lot simpler. All these network errors end up in "fetch finale" and it seems that at that point we could initialize them. That leaves "finalize response". I suppose that for some network errors (in particular CORS) there could be a successful body stream so this would come later. For others that might not happen. Either way, we probably want to report them as soon as possible (i.e., as part of "fetch finale") to avoid leaking timing information. (Which also means "finalize response" (or its callers) has to filter out network errors or some such.) Does that make sense or am I missing something here? |
Yes, that would simplify things!
We're already reporting them in the fetch finale, by calling |
As far as I can tell "fetch finale" does not invoke "process response done"; that's "finalize response". |
6f8c023
to
7575efa
Compare
It does now for the network error case (see new commit, a lot simpler indeed) |
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.
As I tried to point out, this doesn't prevent "finalize response" from being invoked and running "process response done" again. So you need to early exit for network errors there I think.
I also think we want to do something similar for "process response end-of-body". Where we check if the response's body is null, we should also check if it's a network error and do the same thing.
Are you suggesting to omit the timing entry if the network error comes after the body stream has been opened? |
I've added a check for the |
The done flag check is nice! I think there are still some problems:
|
To understand this better, like if it's a network error that became a network after fetch finale? |
@noamr maybe that one isn't needed. I was thinking that step 3 needed to start with "If response is a network error or response’s body is null" to ensure we don't end up reading a network error, but by definition a network error has no body so it should already do the right thing. In the case I was concerned with (CORS error) I forgot that we end up returning a new network error) and basically forget (and don't invoke callbacks) about the network response. If you could double check that I'd appreciate it though. |
It's there on purpose. I want to make sure |
We don't know that progressResponseDone is only used for reporting and callers might well rely on the order; it also seems wrongish for it to happen before the error event as that would be a new timing channel. |
Though I guess perhaps it would more sense to call |
In any case, setting the URL list and timing info for the error response should be done before calling the other callbacks, in case they do the reporting, so I should split this condition into two. |
I double checked, a network error's body is always null, that's explicit in the definition of |
Fixed in new PR, @annevk |
That's not what I meant. Basically when there's a request we get a response from the server. Then we start processing the response while also processing its body in parallel. Processing its body in parallel eventually calls "process response done" (through finalize response), but if processing the response turns into a network error that will also want to call "process response done" (through finalize response). The question is whether the latter always happens before the former. And I don't think that's necessarily the case when integrity is involved as that also awaits the body. Two questions then:
I'd love review from @yutakahirano and maybe @ricea on this, as well as you @noamr and @yoavweiss. |
OK now I understand what you meant. I tried something similar in the new PR amendment. |
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 like the idea of using a task to synchronize. Nice. Couple of remaining nits and it would be really great if we could secure at least one other reviewer.
Fixed nits. Who should we ask to review this? |
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.
As for who else to review: ideally the folks I mentioned earlier.
Chrome is going to implement this once this and tests are ready. |
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.
Using streams in this way seems really nice and reduces the overall complexity a lot. Great work! I do think there are some logic errors here and there, but they seem fixable.
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 whatwg#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
Co-authored-by: Mattias Buelens <649348+MattiasBuelens@users.noreply.github.com>
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.
Revised in the spirit of the comments.
This reverts commit 566580e.
The timing info attached to a network error is always "opaque",
containing only start/end time and the original request URL.
This change currently only applies to the fetch API, and should be
applied to the different callers of FETCCH as part of this and this work.
Closes #1215
[x ] At least two implementers are interested (and none opposed):
Tests are written and can be reviewed and commented upon at:
Implementation bugs are filed:
(See WHATWG Working Mode: Changes for more details.)
Preview | Diff