Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions packages/router-core/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2511,6 +2511,22 @@ export class RouterCore<
...head,
}))
} catch (e) {
if (
e instanceof DOMException &&
e.name === 'AbortError'
) {
const head = await executeHead()
updateMatch(matchId, (prev) => ({
...prev,
status:
prev.status === 'pending'
? 'success'
: prev.status,
...head,
}))
return
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the documentation, the abortController.abort() method throws an Error object of type DOMException with the name AbortError.
When this error is thrown during route loading, it is treated as a normal control flow and the route is updated to a valid state accordingly.

Copy link
Contributor Author

@leesb971204 leesb971204 Jul 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SeanCassiere

I noticed you’ve explored similar concerns before(#4531), so I think it would be great to discuss this approach together.

let error = e

await potentialPendingMinPromise()
Expand Down