react-router icon indicating copy to clipboard operation
react-router copied to clipboard

[Bug]: undefined is not an object (evaluating ' request.signal.aborted ')

Open yxqme opened this issue 1 year ago • 1 comments

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.

yxqme avatar Aug 20 '24 02:08 yxqme

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

BrianWoolfolk avatar Oct 04 '24 21:10 BrianWoolfolk

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.

brophdawg11 avatar Apr 09 '25 13:04 brophdawg11