Skip to content

Commit cf5519c

Browse files
committed
test: abort the superseding navigation instead of leaving it in flight
The supersede assertion drove its second navigation with a fetch that never settled, which left a navigation in flight for the rest of the page's life holding the router's token and its own frame state. Under the full browser suite that leak reded an unrelated file, the #1310 back-restore residue assertion, on Firefox, while both files passed in isolation and while the branch's own file passed everywhere. Rejecting with an AbortError settles the navigation down the path the router already takes for a superseded one, so the assertion observes the same thing with nothing left running. Full browser suite green twice at this commit, against a baseline that was green before the file was added.
1 parent 374ee58 commit cf5519c

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

packages/core/test/routing/browser/nav-swipe-ab-levers.test.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,23 @@ suite('Client router: back-swipe A/B levers (#1428)', () => {
165165
window.scrollTo = function (...args) { scrolls.push('scroll'); return origScrollTo.apply(this, args); };
166166
await navigate(location.origin + '/swipe-ab-superseded');
167167

168-
// Start a second navigation inside the deferred scroll's frame gap. Its
169-
// fetch never settles, so it bumps the nav token and then does nothing
170-
// else, which isolates the guard from anything the newer navigation
171-
// would itself have done to scroll.
172-
window.fetch = () => new Promise(() => {});
173-
navigate(location.origin + '/swipe-ab-superseder');
168+
// Start a second navigation inside the deferred scroll's frame gap. It
169+
// bumps the nav token and then does nothing else, which isolates the
170+
// guard from anything the newer navigation would itself have done to
171+
// scroll.
172+
//
173+
// Aborted rather than left pending. A fetch that never settles leaves a
174+
// navigation in flight for the rest of the page's life, holding the
175+
// router's token and its own frame state, and a test that never cleans
176+
// that up is a leak looking for somewhere to surface. An AbortError is
177+
// the shape the router already treats as a superseded navigation, so it
178+
// settles down the path it would take in production.
179+
let abortPending;
180+
window.fetch = () => new Promise((_, reject) => { abortPending = reject; });
181+
const superseder = navigate(location.origin + '/swipe-ab-superseder');
174182
await settleFrames();
183+
if (abortPending) abortPending(new DOMException('aborted', 'AbortError'));
184+
await superseder.catch(() => {});
175185

176186
// Without the token guard the first navigation's scroll fires here, into
177187
// a document a newer navigation already owns.

0 commit comments

Comments
 (0)