Repository navigation
test: pin the fake clock in the useSubscription deadline-report test - #22209
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🎨 Storybook: ✅ Built — View Storybook🧩 Custom Nodes Ecosystem Matrix: 🟡 Withheld — could not measureExecutes the frontend JS of every registry pack that ships any, against this change, in both renderers. The eight
Findings and check detailsThe matrix runs on same-repository version-bump PRs with relevant changes, main-branch pushes, and manual dispatches. This candidate does not qualify, so every expensive stage was skipped. Reproduce locally# build one shard's fixture, then run it
python3 scripts/registry-census/build_matrix.py --shard 1/4
MATRIX_RENDERER=vue MATRIX_VUE=1 \
npx vitest run --config vitest.matrix.config.mts
Full docs: scripts/registry-census/README.md 🌾 Fallow: ✅ PassedFallow audits the diff for duplication, complexity and dead code. It gates on new findings only, so when the audit completes, a red is something this PR introduced or moved — never inherited backlog. A red can also mean the audit itself did not finish; the details below say which happened. Findings and check detailsNo new findings in the changed files. Reproduce locally# the base the gate compared against
npx fallow audit --root . --quiet --format json \
--changed-since ba3a8928e7a41b10cbea4f227c6ef476821c9462
Full docs: ADR-DEVEX-LINT-0015 🏛️ Architecture: ✅ PassedFindings and check detailsWarnings (273)
Reproduce locallypnpm architecture:checkFull docs: Frontend domain catalog |
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Deadline test timer setup src/platform/billing/subscription/composables/useSubscription.test.ts |
The test uses fake timers with automatic time advancement disabled. |
Priority:
Estimated code review effort: 1 (Trivial) | ~3 minutes
Change: Bug fix
Possibly related issues
- Issue 15782 — Both concern the repository’s fake-timer setup. This change disables automatic advancement for the deadline test, but does not address the issue’s documentation work.
Possibly related PRs
- Comfy-Org/ComfyUI_frontend#22083 — This PR also disables automatic fake-timer advancement in a test to prevent timing-related flakes.
- Comfy-Org/ComfyUI_frontend#22038 — This PR also disables automatic fake-clock advancement in a test.
Suggested reviewers: drjkl
Merge Risk: 
Minimal · up to 66a66
-
This scoped test-only timer change is ready to merge.
Pre-merge checks: 
6
-
Full details: Title check
-
Explanation
The title names the test file and the specific change (pinning the fake clock in the deadline-report test). It matches the single-line change that sets fake timers with shouldAdvanceTime disabled, so it is accurate and specific. The 68-character length is acceptable, and the conventional 'test:' prefix fits the change.
Full details: Description check
-
Explanation
The description follows the template. It has an ELI5 section and a Summary that explains the cause (shared Vitest setup uses shouldAdvanceTime: true, which moves the clock during an async advance) and the fix. The Verification section gives concrete test commands, run counts, a revert check, and lint/format/typecheck results, and it lists what was not run. The template's Summary asks for 1-2 sentences, and this Summary is longer. The optional issue-link line is absent, which is acceptable because the template marks it as optional. The Residual section notes a remaining risk for other tests.
Full details: End-To-End Test Suggestion For User-Facing Changes
-
Explanation
The pull request changes only
src/platform/billing/subscription/composables/useSubscription.test.tsto configure fake timers for a test. It does not fix or add a user-facing frontend feature, and it does not require an end-to-end test.
Full details: Adr Compliance For Entity/Litegraph Changes
-
Explanation
The changed file is
src/platform/billing/subscription/composables/useSubscription.test.ts. It is not undersrc/lib/litegraph/,src/ecs/, or a graph-entity-related path. The custom check does not apply.
-
Finishing Touches: 💡 1
-
🛠️ Fix failing CI checks: 💡
-
- Commit to this branch
- Create a new PR
📝 Generate docstrings
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
There was a problem hiding this comment.
🔍 Cursor Review — Consolidated panel
Triggered by @mattmillerai.
✅ No high-signal findings.
Panel: 6/6 reviewers contributed findings.
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #22209 +/- ##
==========================================
- Coverage 87.46% 87.36% -0.11%
==========================================
Files 2923 2815 -108
Lines 158649 155262 -3387
Branches 43467 42295 -1172
==========================================
- Hits 138760 135639 -3121
+ Misses 18968 18868 -100
+ Partials 921 755 -166
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
dante01yoon
left a comment
There was a problem hiding this comment.
Approving. The root cause holds up: the global vi.useFakeTimers() in vitest.timer.setup.ts auto-advances the clock, which can push an exact-boundary assertion (556_999 then +1) past the 600,000 ms deadline. Scoping shouldAdvanceTime: false to this one test matches the existing opt-outs (JobAssetsList.test.ts, GraphCanvas.test.ts), and the global afterEach already restores real timers. The revert check in the description (2 of 3 cold runs fail without the line) is enough evidence that the flake is real.
|
Merging at the approved head |
…NT-3485) (Comfy-Org#22481) ## Summary Fixes the `useAgentSession` g6 and g18 tests, which failed when run alone and flaked in the agent suite. The suite's fake clock has `shouldAdvanceTime: true`, so it also follows real time. Both tests assert a timer boundary, and a cold start spends enough real time to cross it. g6 failed every time alone: `getMessages` had already run twice after advancing 999 ms. g18 failed 1 of 5 runs alone on main. Both tests now call `vi.useFakeTimers({ shouldAdvanceTime: false })`, the same fix as Comfy-Org#22209. Test-only: production recovery timing is unchanged. ## Verification - g6 alone: failed 3/3 before, passed 13/13 after. - g18 alone: 4/5 before, 8/8 after. - `useAgentSession.test.ts` in full: 313 passed. Fixes FRONT-3485
…omfy-Org#22666) ## What Pins the fake clock in the AgentPanel test "locks immediately but only shows the conversation veil for a slow opening": `vi.useFakeTimers({ shouldAdvanceTime: false })`. ## Why Fixes FRONT-3700. The test asserts the veil is still hidden at 119 ms of its 120 ms delay. The suite default (`fakeTimers: { shouldAdvanceTime: true }` in `vite.config.mts`) lets real elapsed time move the fake clock too, so on a loaded machine the clock can pass 120 ms before that check and the veil already shows. It failed once that way in a full `src/workbench/extensions/agent` run and passed alone. Same cause and fix as the useSubscription deadline test (Comfy-Org#22209); the next test in this file that asserts an exact boundary already pins it the same way. ## Proof - Red: with the default clock and a temporary 60 ms real sleep inserted before the 119 ms advance (simulated load), the test failed with `expected <div role="status" …> to be null`, the reported failure. - Green: with the clock pinned and the same 60 ms sleep still in place, it passes. The sleep is not committed. - Whole file: 31/31 pass. Test-only, one file, inside `src/workbench/extensions/agent/**`.
ELI5
One billing test sometimes failed the first time it ran even though the code it checks works fine. Its fake clock kept moving forward on its own, so a deadline check fired one step early. This change stops that clock from auto-advancing for that one test, so it gives the same result every run.
Summary
The shared Vitest setup installs fake timers with
shouldAdvanceTime: true. sinon's auto-advance interval callstick(20)every 20 real ms. When that tick lands during a yield insidevi.advanceTimersByTimeAsync, the advance target moves 20 ms further, so43_000 + 556_999puts the clock at 600,019. The 600,000 ms deadline wake-up then fires one assertion early. A cold worker running this test alone always takes longer than 20 real ms, so the failure showed up deterministically on the first run.The fix is test-only: re-install
vi.useFakeTimers({ shouldAdvanceTime: false })as the first statement ofreports at the deadline without another lifecycle event. This is the repo's established opt-out (seeuseWorkspaceAuth.test.ts,JobAssetsList.test.ts,ModelLibrarySidebarTab.test.ts). The globalafterEachinvitest.timer.setup.tsalready restores real timers. The opt-out is scoped to this one test on purpose: four other tests in the file rely on auto-advance forsetTimeoutflushes andvi.waitFor. ProductionuseSubscription.tsandvite.config.mtsare unchanged.Verification
--retry=0: 10/10 passCI=true --retry=0: 96/96 pass--retry=0: 96/96 passtypecheck:app: cleanuseFakeTimers/useSubscriptionmentions; none describe this test's timer setup)Provenance
--retry=0typecheck:app)pnpm test:unit,pnpm knip, full CI matrixResidual
None. This only changes the one test it targets. The underlying
shouldAdvanceTimeinteraction may still make other tests flaky when they assert on exact fake-clock boundaries; this PR did not sweep the corpus for them.