Commit 8955995
test(cli): pay the cloud-connection transform at module load, out of the clocked window (#17659)
`optional-package.test.ts`'s end-to-end control — "resolves a real workspace
package rather than mistaking it for absent" — called
`loadOptionalPackage('@objectstack/cloud-connection')` inside vitest's default
5000ms `testTimeout`. With `packages/cloud-connection/dist` built it took
5005ms / 5043ms across two runs and timed out; the same import in plain node
from `packages/cli` takes 856-1003ms on the same box.
The gap is not import cost. Every workspace package here is a pnpm link whose
realpath carries no `/node_modules/` segment, so vitest's default
`server.deps.external` inlines it — `dist/` included — and the probe paid a
cold whole-package source-graph transform inside the clock.
Fix is the one `scripts/check-test-source-alias.mjs` prescribes in its
clocked-window rule and that five sibling `packages/cli` test files already
carry verbatim: a module-top side-effect import, so the transform is paid
during collection, which vitest clocks against nothing. The timeout is NOT
raised — the budget is the only thing currently reporting the cost.
The assertion is untouched: the `it()` still calls `loadOptionalPackage()` on
the real specifier and still asserts `state === 'loaded'`, so a genuinely
absent or broken package still fails it.
Claude-Session: https://claude.ai/code/session_01TSf4DV7ziu4V5j73e46b7c
Co-authored-by: Claude <noreply@anthropic.com>1 parent 5ddd5d3 commit 8955995
1 file changed
Lines changed: 27 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
36 | 63 | | |
37 | 64 | | |
38 | 65 | | |
| |||
0 commit comments