Skip to content

[Test] TreeShaking runs four Bun.build calls across three test bodies against bun's 5 s default, carrying 3.7x the exposure of the test that already timed out #1394

Description

@pathosDev

Problem

tests/unit/TreeShaking.test.ts runs Bun.build four times across three test bodies, none of which declares a third argument, so all four run against bun's 5 000 ms per-test default. It is the same shape as #1392 — bounded work with no failure budget, sitting on the runner's clock — and it carries more exposure than the test that actually timed out.

It has not been observed failing. This is preventive, and filed at priority: low for that reason.

Evidence

Per-test durations, junit reporter, this worktree at a21ea07b, bun 1.4.0, Windows 11, idle machine:

test isolated under --coverage
package.json declares sideEffects: false 0.6 ms 0.6 ms
importing Actor does not drag in the embedded DevTools UI 66.5 ms 19.4 ms
the canary is a real one — the DevTools entry does carry the UI 30.1 ms 30.8 ms
a narrow import is a rounding error next to the whole barrel 109.7 ms 75.7 ms

The worst body is 109.7 ms against 29.1 ms for CoreStaticImports' failing test — 3.7x the exposure, on the same cap, with the same absence of a declared timeout. The multiplier that took 29.1 ms to 6 723.89 ms would take 109.7 ms to roughly 25 s.

a narrow import is a rounding error is the worst because it builds twice (narrow and everything), and its narrow build compiles a source string byte-identical to the one importing Actor does not drag in the embedded DevTools UI already built — so one of the four builds is pure duplication.

Proposed fix

The same remedy as #1392, for the same reason: hoist the builds to module scope, which carries no per-test timeout. bundleSize is async, so this needs top-level await — already used in the test tree at tests/integration/in-process/persistence/journals/NodeSqliteDriver.test.ts:22.

Hoisting also removes the duplicate build, taking four down to three, and the test bodies become assertions over precomputed bundles.

Explicitly not proposed: a third argument. Same argument as #1392 — that remedy is for a failure budget meant to expire and print a label, and a bundle build has none.

Acceptance

  • No Bun.build call runs inside a test() body.
  • All five assertions unchanged: sideEffects: false; the narrow bundle must not contain UiAssets; the DevTools entry must; and the narrow bundle must be under both 5 % of the full barrel and 50 000 bytes.
  • The duplicate build is gone.
  • Green under ACTOR_TS_SKIP_FLAKY_MNS=1 bun run test:coverage:gate.

Related: #1392, #1376.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinginfrastructureCI / build / live-integration testspriority: lowNice-to-have / niche / demand-driven

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions