-
Notifications
You must be signed in to change notification settings - Fork 541
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
AbortSignal.timeout inconsistently leads to TimeoutError or AbortError #2171
Comments
I'm not sure I see a problem here? The current behavior makes sense to me. |
I would expect to get a You can see the alternative error by shortening the timeout on the const response = await fetchWithTimeout("https://google.com/", {
timeout: 10,
}); which will then cause a |
I'm pretty sure this is spec compliant. |
Ah, you might be right https://dom.spec.whatwg.org/#ref-for-dom-abortsignal-timeout%E2%91%A0. @KhafraDev |
fetch is expected to only throw an AbortError (previous discussion about this starts here). |
That is definitely not the case right now. As mentioned above fetch will throw |
Also the linked comment refers to user supplied reasons which isn't the issue that I have here. |
this seems to indicate the functionality was added to the spec: https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/timeout_static and running this on FIrefox (on Google): fetch("https://www.google.com/", {signal: AbortSignal.timeout(100)}).catch(e => console.log(e.name)) yields |
I'm inclined to think that is a bug in Firefox, the spec doesn't mention TimeoutError at all. It mentions AbortError for timeouts. |
The DOM spec does mention it, however: |
I'm leaning towards that you might be wrong here... |
Yeah I was, we weren't forwarding the reason. Will have a PR up soon. |
* fix: forward error reason to fetch controller Fixes #2171 * fix: update spec text * fixup
Great to see that it's fixed. Can't wait to have it oficially released. Is there any release schedule? |
* fix: forward error reason to fetch controller Fixes nodejs#2171 * fix: update spec text * fixup
Bug Description
If
fetch
is passed aAbortSignal.timeout(timeout)
as the signal and the timeout occurs, aTimeoutError
is raised in certain cases whereas in other cases aAbortError
is raised. TheTimeoutError
occurs when the fetch itself times out whereas theAbortError
is raised if the timeout occurs while streaming the response.Reproducible By
Expected Behavior
An error of the format:
Logs & Screenshots
Instead we get:
Environment
MacOS: 12.6
Node: v19.9.0
Additional context
The text was updated successfully, but these errors were encountered: