-
-
Notifications
You must be signed in to change notification settings - Fork 219
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
fetch(..., { signal: AbortSignal.timeout(...) })
throws AbortError
instead of TimeoutError
when timeout happens
#1718
Labels
bug
Something isn't working
Comments
Also if a custom abort reason is used, it should copy it too: it('happy-dom', async () => {
try {
const c = new AbortController()
setTimeout(() => {
c.abort('Foo')
}, 10)
await fetch('https://example.com', { signal: c.signal })
} catch (e) {
expect(e).toStrictEqual('Foo')
}
}) Output:
|
capricorn86
added a commit
to btea/happy-dom
that referenced
this issue
Feb 21, 2025
capricorn86
added a commit
to btea/happy-dom
that referenced
this issue
Feb 21, 2025
capricorn86
pushed a commit
that referenced
this issue
Feb 21, 2025
Thank you for reporting @Frederick888! 🙂 Thanks to @btea, there is a fix in now. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
When
fetch()
is aborted due to a timeout signal, theDOMException
's name isAbortError
instead ofTimeoutError
.To Reproduce
I'm using happy-dom in Jest to test some code similar to the MDN example https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/any_static#using_abortsignal.any.
Output:
Expected behavior
It throws a
DOMException
whose name isTimeoutError
and message isThe operation timed out.
(like Firefox) orsignal timed out
(like Chrome).Screenshots
N/A
Device:
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: