Files
romm/frontend/src/plugins/transition
Sam Dornan c9d0b0da12 fix(v2): stop the unhandled rejection when a view transition is preempted (#4570)
* fix(v2): absorb the skipped transition preemption rejects

Activating a game card starts a shared-element morph, and navigating
inside it starts the router's own view transition. The browser skips the
older of two overlapping transitions, rejecting its `ready` promise with
an AbortError that nothing consumed, so it surfaced as an unhandled
rejection on every forward card activation. Back navigation preempts the
same way in the other order: the router's transition starts first and the
back-morph skips it.

Absorb the skip at both leaking sites, in the transition plugin wrapper
(only `captured` is awaited) and in `morphTransition` (only `finished` is
consumed). Both transitions are still created and one still animates, so
the morph behaviour is unchanged.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(v2): absorb the preemption skip at every transition site

The router's wrapper absorbed the AbortError a preempted transition
rejects `ready` with, but the two transitions the v2 morph code starts
directly did not. Move the handling into one exported helper used at all
three sites, so the back-morph preempted by a navigation during its
capture phase no longer leaks an unhandled rejection.

The helper rethrows any reason that is not an AbortError, so a genuine
transition failure stays visible instead of being swallowed.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* test(v2): share the view transition test fixtures

Both transition test files carried their own copy of the
startViewTransition stub, and the unhandled-rejection probe was inlined
in one and rebuilt in the other. Move them to src/test-utils, next to
serverError, so there is one stub to keep in step with the API.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* test(v2): drive the back-morph guard through a real router

The fake router and route fixtures needed `as unknown as` casts, which
the v2 component rules prohibit. A memory-history router gives the guard
real route objects instead, so the test drops the casts and exercises the
registration it actually ships with.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-16 22:27:06 -05:00
..