Skip to content

Warm up viewer dynamic imports in a beforeAll hook so the pre-push gate doesn't flake under load - #2320

Merged
mstomar125 merged 1 commit into
mainfrom
issue-2293-flaky-viewer-resolution-test
Aug 31, 2026
Merged

mstomar125 merged 1 commit into
mainfrom
issue-2293-flaky-viewer-resolution-test

Conversation

@mstomar125

Copy link
Copy Markdown
Contributor

Problem

src/tests/plugins/core-plugins.test.ts's "should resolve viewer components for plugins with viewers" test's first assertion pays the one-time cost of Vite transforming BaseNodeViewer's whole ~1500-line subtree (~20 direct imports) on the first dynamic import() of a viewer component. Every import() after that resolves from the module cache in well under a millisecond, since date/task's viewer.lazyLoad closures (registered by reference via registerCorePlugins) are the exact same import() calls made in the test body.

This is genuine, load-sensitive compile work — not a hang and not a resource leak from an earlier test. Measured locally: ~2.1-2.3s idle, up to ~4.5s under heavy concurrent CPU load (8-way contention on a 10-core machine). Against the default 5s testTimeout, that left effectively no headroom under real machine load — which is exactly what hit this session twice today on two unrelated PRs' pre-push gates.

Fix

Warms both lazyLoad closures in a beforeAll hook (30s timeout — generous on purpose, since this is deliberately where the compile cost is meant to land) so the actual test assertions measure only the already-warm resolution, restoring the 5s testTimeout as a meaningful regression guard instead of a race against a one-time compile cost with no headroom.

Testing

  • Ran the affected test file in isolation 3x after the fix: consistently ~2.1-2.3s total, well within the 5s per-test bound.
  • bun run test:all: clean, no new failures.
  • bun run quality:fix: clean.
  • Pushed through the real pre-push gate (test:all + cargo build + test:e2e) — passed.

Closes #2293.

…te doesn't flake under load (closes #2293)

The viewer-resolution test's first assertion pays the one-time cost of
Vite transforming BaseNodeViewer's whole ~1500-line subtree (~20 direct
imports) on the first dynamic import() of a viewer component. Every
import() after that resolves from the module cache in well under a
millisecond, since date/task's viewer.lazyLoad closures are the exact
same import() calls made in the test body.

Measured locally: ~2.1-2.3s idle, up to ~4.5s under heavy concurrent
CPU load (8-way contention on a 10-core machine) -- genuine,
load-sensitive compile work, not a hang or a resource leak from an
earlier test. Against the default 5s testTimeout, that left effectively
no headroom under real machine load, which is exactly what this
session hit twice today on two unrelated PRs' pre-push gates.

Warms both lazyLoad closures in a beforeAll hook (30s timeout --
generous on purpose, since this is deliberately where the compile cost
is meant to land) so the actual assertions measure only the
already-warm resolution, restoring the 5s testTimeout as a meaningful
regression guard instead of a race against a one-time compile cost.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@mstomar125
mstomar125 merged commit 43b52ec into main Aug 31, 2026
@mstomar125
mstomar125 deleted the issue-2293-flaky-viewer-resolution-test branch August 31, 2026 11:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

core-plugins viewer-resolution test sits at 3.5s of a 5s timeout and fails the pre-push gate under load

1 participant