Replies: 3 comments
-
|
You're right that they're benign, and your The router fires the transition and walks away. In Your guard checks state at navigation start, but these rejections are about interruption timing, which happens later:
None of those are visible to the check you wrote, because at the point they fire the transition is already running. Since the router owns that promise and doesn't hand it to you, there's no per-navigation hook to catch it yourself. The clean stopgap is a global handler that swallows exactly these: window.addEventListener('unhandledrejection', (e) => {
const err = e.reason
if (
err instanceof DOMException &&
['AbortError', 'InvalidStateError', 'TimeoutError'].includes(err.name) &&
/transition/i.test(err.message)
) {
e.preventDefault() // benign view-transition churn, don't report it
}
})
The actual fix belongs in the router: capture the |
Beta Was this translation helpful? Give feedback.
-
|
This traces back to a real gap in the router's own view transition handling, not application code. In The The Filtering them out in Sentry is a reasonable stopgap given the router doesn't guard against this itself. A more surgical version: attach a global capture before Sentry's own listener that swallows only rejections whose reason is one of these specific DOMException names when the message also matches this wording, then rethrow anything else, keeping real unrelated AbortErrors visible. The durable fix belongs in the router itself though: wrapping the |
Beta Was this translation helpful? Give feedback.
-
|
The AbortError/InvalidStateError/TimeoutError from view transitions is typically caused by the browser's navigation timing out during a document transition. The fix is to wrap your view transition logic: import { startViewTransition } from "../utils/viewTransition"
if (typeof document !== "undefined" && "startViewTransition" in document) {
try {
const transition = document.startViewTransition(() => updateDOM())
await transition.finished
} catch (err) {
if (err instanceof DOMException && err.name === "AbortError") {
// View transition was superseded by another navigation — safe to ignore
return
}
throw err
}
}TanStack Router's You can suppress Sentry noise by filtering in your beforeSend(event) {
if (event.exception?.values?.[0]?.type === "AbortError") return null
return event
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
After enabling view transitions in our app a few months ago we have steadily getting unhandled-rejection errors in production from users on Chrome / Edge
Our router config:
We also have a few pages with custom slide left/right transitions via links:
Even with this guard in place, the errors keep happening.
The only "fix" i have found is to exclude these from Sentry, as they seem to be benign errors not noticeable to users
Is there a recommended way to handle this, or should i just silence the errors for now?
I was able to replicate Transition Aborted error on this Stackblitz, but only when the tab updates in the background. i.e having a preview tab open and making changes in the editor.
Related Links:
Beta Was this translation helpful? Give feedback.
All reactions