Repository navigation
test(octane): hold the frame clock in the pre-render passive ViewTransition test - #1902
Merged
Merged
Conversation
…sition test "commits without animation when a pre-render passive adds urgent sibling work" relies on a passive effect from a sync commit still being pending when the transition's host task (#1873) starts rendering. In the test, that passive is drained at the next animation frame, which then posts to the runtime's long-lived post-paint port. When jsdom's frame timer comes due before the transition task runs, as it can on a loaded CI worker, the passive drains first and the transition animates. The test's capture mock never runs the update, so the left scope stays 'initial', and `vi.waitFor` timed out in octane-prod on #1893. The test now fakes setTimeout and requestAnimationFrame, so no frame and no fallback timer can drain the passive early. It waits for the transition with a host task posted after the runtime's, not by polling, because `vi.waitFor` would advance the fake timers. The host-task `nextTask()` helper moves to tests/_helpers.ts. It replaces the local copies in view-transition.test.ts and view-transition-matching.test.ts. #1875 already made the matching tests wait for the native transition start. Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
marked this pull request as ready for review
October 8, 2026 14:41
Contributor
Benchmark report🟢 No budget breaches, no added work, and no timing changes beyond ±3%. Compares js-framework: 1k/10k row operationsAll 20 timed operations (20 without a verdict)
All 64 work counters are unchanged. Application bundle size (bytes)No changes across 60 measured values. Public-import reachability bundles (bytes)No changes across 111 measured values. |
4 of 7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This makes "commits without animation when a pre-render passive adds urgent sibling work" (
view-transition-scoped-effects.test.ts) deterministic. It failed inoctane-prodon #1893 withexpected 'initial' to be 'left changed'.It also moves the host-task
nextTask()wait intotests/_helpers.ts, so the ViewTransition suites share one copy.Why
The test needs a passive effect from a
flushSynccommit to still be pending when the transition renders. Since #1873, that render runs in its own host task, which drains pending passives before it chooses capture owners.In jsdom, the passive drains at the next animation frame instead. The frame posts to the runtime's long-lived post-paint
MessagePort. Node delivers pending port messages in port-creation order, so once jsdom's frame timer comes due before the transition task runs, the passive goes first.On a loaded CI worker, that is what happened:
update(), soleftstays'initial'.vi.waitFortimes out after 1 s.Neither order is a runtime defect. The test simply targets the "transition task before the next frame" case. So the test now controls the frame clock, and the runtime is unchanged.
The other two flakes from #1893 are in
view-transition-matching.test.ts. #1875 already fixed them onmainby waiting for the mock'sstartViewTransitioncall. The forced reorder below confirms that fix holds.Changes
view-transition-scoped-effects.test.ts: the test fakessetTimeout,clearTimeout,requestAnimationFrameandcancelAnimationFrame, so neither a frame nor the 250 ms fallback timer can drain the passive early.nextTask(), a host task posted after the runtime's, instead of polling.vi.waitForwould advance the fake timers.afterEachrestores real timers.tests/_helpers.ts: addsnextTask(). It takes over the identical local copies inview-transition.test.tsandview-transition-matching.test.ts, and capturesMessageChannelat load so a test that stubs it cannot break the helper.Validation
To reproduce the CI ordering locally without loading the machine, I applied a temporary patch to
postHostTask(not committed). After posting, it spins 20 ms of wall clock in a microtask, so timers come due before the event loop reaches the transition task.main, three VT files:view-transition-scoped-effects.test.tsfails in both--project octaneand--project octane-prod, with CI's exact message:expected 'initial' to be 'left changed'.'before'vs'after','insertion:urgent'first), plus two latent ones in that file.view-transition-{matching,scoped-effects}.test.tsandview-transition.test.tspass 61/61 in bothoctaneandoctane-prod.routeFlush's pre-capture passive drain disabled, the fixed test fails, so the assertion still guards the behavior.pnpm format:files:checkon the changed filespnpm sync: no changespnpm typecheck:fileson the changed tests and their fixtures: no errors in changed lines. The only test-file error is the untouched../src/compiler/compile.jsimport inview-transition.test.ts; the rest are in the untouched.tsrxfixtures.pnpm format:check,pnpm typecheckandpnpm testwere not run locally, under the parallel-session load rule. CI covers them.Risk / follow-ups
vi.waitFor, so holding its frames would need the same rewrite.Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Low Risk
Test-only refactors and timer fakes; no runtime, auth, or production behavior changes.
Overview
Test-only changes that stabilize ViewTransition timing in Octane’s Vitest suite and deduplicate host-task waiting.
A shared
nextTask()helper is added totests/_helpers.ts(MessageChannel-based wait for work scheduled after the runtime’s transition host task). The duplicate local implementations are removed fromview-transition.test.tsandview-transition-matching.test.ts, which now import the shared helper.MessageChannelis captured at module load so stubs cannot break the helper.In
view-transition-scoped-effects.test.ts, the case “commits without animation when a pre-render passive adds urgent sibling work” is made deterministic: it fakessetTimeout/requestAnimationFrameso a jsdom animation frame cannot drain the passive before the transition task, asserts the intermediate DOM state, then advances withnextTask()instead ofvi.waitFor(which would advance fake timers).afterEachrestores real timers.No production/runtime code changes.
Reviewed by Cursor Bugbot for commit ef0e35f. Bugbot is set up for automated code reviews on this repo. Configure here.