-
Notifications
You must be signed in to change notification settings - Fork 2k
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() in fetch request always responds with AbortError but not TimeoutError in chromium based browser #20381
Comments
This is clearly a bug in Chromium-based browsers. The specs say:
Did you report it to Chromium? Depending on the response we may want to add a note in the BCD table. |
Yes I have opened an issue in chromium, |
Let's wait for an answer there, then. They may have a rationale for why they deviated from the spec (besides not being precise). |
This is confirmed to be a Chromium bug. It should be transferred to BCD. |
I cannot reproduce the issue with Chrome 129, and this example: getData = async function () {
const signal = AbortSignal.timeout(1);
try {
const response = await fetch("https://www.example.com/", {
signal,
});
console.log(response);
} catch (err) {
console.log("signal.reason", signal.reason);
console.log("error.name", err.name); //AbortError
}
};
getData(); Both |
The fix was in this commit belonging to bug 40071725 (which has milestone 119, but was backed out and re-applied in 124). |
MDN URL
https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/timeout
What specific section or headline is this issue about?
No response
What information was incorrect, unhelpful, or incomplete?
I have following code:
Here, getData uses
fetch()
to retrieve data from an API endpoint, I setsignal
property of request toAbortSignal.timeout(5_000)
to implement timeout.According to the docs,
AbortSignal.timeout(TIME_IN_MS)
will returnAbortSignal
that will automatically abort after specified time. The signal aborts with eitherTimeoutError
on timeout, or withAbortError
due to pressing a browser stop button, closing the tab (or some other inbuilt "stop" operation).The response that I get every time when running
getData()
isAbortError
with messageThe user aborted a request.
and neverTimeoutError
, even when I set browser to throttle to slow 3G and set time to 100ms. I also tried setting the response to take 10s in the server and in the front end to no throttle and timeout to 9000ms.This happens only for chromium-based browsers like Google Chrome and Microsoft Edge, but produces expected output in Firefox browser.
What did you expect to see?
TimeoutError
as stated in chromium-based browsers like stated in the docs.Do you have any supporting links, references, or citations?
In Chromium Based Browsers (Microsoft Edge and Google Chrome):
In Firefox Browswer:
Do you have anything more you want to share?
No response
MDN metadata
Page report details
en-us/web/api/abortsignal/timeout
The text was updated successfully, but these errors were encountered: