Skip to content

Commit b74a069

Browse files
arturovtpkozlowski-opensource
authored andcommitted
fix(router): handle errors from view transition finished promise
This commit adds a `.catch()` handler to `transition.finished` from `document.startViewTransition` to prevent unhandled promise rejections. The finished promise can reject with `TimeoutError` or `InvalidStateError` when transitions fail during or after the animation phase. Based on the Blink source code, the `finished` promise can reject with: * `TimeoutError`: "Transition was aborted because of timeout in DOM update" * `InvalidStateError`: "Transition was aborted because of invalid state" This may happen when the DOM update phase exceeds the browser's internal timeout threshold.
1 parent 819b640 commit b74a069

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

packages/router/src/utils/view_transition.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ export function createViewTransition(
9999
console.error(error);
100100
}
101101
});
102+
transition.finished.catch((error) => {
103+
if (typeof ngDevMode === 'undefined' || ngDevMode) {
104+
console.error(error);
105+
}
106+
});
102107
const {onViewTransitionCreated} = transitionOptions;
103108
if (onViewTransitionCreated) {
104109
runInInjectionContext(injector, () => onViewTransitionCreated({transition, from, to}));

0 commit comments

Comments
 (0)