-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
[Bug]: Error with message of "... call aborted" is thrown instead of standard DOMException #9629
Comments
Yeah I don't see any reason not to do this (pun very much intended) 😉 . Want to push up a PR? |
@brophdawg11 great 👍 , I'll push a PR soon |
So, it seems like it won't work because of a polyfill used mysticatea/abort-controller#33 I also tried to not use polyfill by removing "setupFiles" option from jest config (node supports fetch since version 18 without a flag https://nodejs.org/api/globals.html#fetch). But for some reason tests error with "Request is not defined". And that's strange, because if I add @brophdawg11 do you have any idea on what could be wrong? |
@brophdawg11 Does it make sense to drop polyfill and depend on fetch apis from node 18? Or it's not worth to even try for now? |
Hm - not offhand. My hunch is that there's something also polyfilling down inside if (request.signal.reason instanceof Error) {
throw request.signal.reason;
} else {
throw new Error("queryRoute call aborted");
} |
Hm, yes. We can only get rid of the polyfill here and use |
This issue has been automatically marked stale because we haven't received a response from the original author in a while 🙈. This automation helps keep the issue tracker clean from issues that are not actionable. Please reach out if you have more information for us or you think this issue shouldn't be closed! 🙂 If you don't do so within 7 days, this issue will be automatically closed. |
This issue has been automatically closed because we didn't hear anything from the original author after the previous notice. |
What's the recommended best practice here? Always wrap |
Yes - you should always wrap that in case it throws from being interrupted by another request. |
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
I can take a look at this again now that v2 is node 18+ and polyfills are user-driven |
Great to hear! Looking forward on resolving this! |
This comment was marked as duplicate.
This comment was marked as duplicate.
🤖 Hello there, We just published version Thanks! |
🤖 Hello there, We just published version Thanks! |
What version of React Router are you using?
6.4.3
Steps to Reproduce
Launch
examples/ssr-data-router
withnpm run dev
. Open it in browser and either click Refresh/Stop browser button or press Ctrl/Cmd+R without a pause.Expected Behavior
AbortSignal.prototype.reason is thrown, which defaults to
DOMException
with the name'AbortError'
(or whatever you pass toabort
method) and it's relatively easy to distinguish from other errors with code likeerr instanceof DOMException && err.name === 'AbortError'
or matching with whatever value the user passes to.abort
.Actual Behavior
Error
instance with message"... call aborted"
is thrown (can be seen in output of the running server), which needs custom logic matching error message to distinguish it from other errors.The relevant code throwing that error exists inside submit and loadRouteData.
Replacing both of those lines with
throw request.signal.reason;
would throw expected error, which isDOMException
with'AbortError'
by default or whatever the user passes to.abort
call.If there are no good reasons to keep it as it is, I'm more than happy to submit a PR for that change.
The text was updated successfully, but these errors were encountered: