react-router
react-router copied to clipboard
[Bug]: undefined is not an object (evaluating ' request.signal.aborted ')
What version of React Router are you using?
react-router-dom 6.26.1
Steps to Reproduce
Use lazy loading for the page.
lazy: () => import("./pages"),
In browsers that do not support request.signal For example, iOS phone version 13.6. The following code will throw an error undefined is not an object (evaluating ' request.signal.aborted ')
if (request.signal.aborted) {
// Handle aborted request
}
Can it be changed to the code below to improve compatibility?
// ... existing code ...
if (request.signal && request.signal.aborted) {
// Handle aborted request
}
// ... existing code ...
Expected Behavior
Do not throw an error.
Actual Behavior
Threw an error.
It's there a PR about this? I think request.signal?.aborted would be simpler. Being such a small fix, I could send a PR in a moment
The request signal is core to the routers capability to handle interruptions and cancellations so I think making that check defensive would cause more problems than it would fix. It looks like this should be present back through iOS 12.2: https://caniuse.com/mdn-api_request_signal.