react-router: [Bug]: Error with message of "... call aborted" is thrown instead of standard DOMException
What version of React Router are you using?
6.4.3
Steps to Reproduce
Launch examples/ssr-data-router
with npm 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 to abort
method) and it’s relatively easy to distinguish from other errors with code like err 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 is DOMException
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.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 18 (12 by maintainers)
I can take a look at this again now that v2 is node 18+ and polyfills are user-driven