Skip to content

Commit 2b1d031

Browse files
authored
test(lint): give the lazy-deps dist probes the same cold-load timeout as their sibling (#3662) (#3708)
The two dist probes spawn a child `node` that cold-loads sucrase (~1.5 MB) and typescript (~9 MB) to prove neither comes in at import time. That cold load alone exceeds vitest's default 5s timeout on a loaded runner — a whole-repo `pnpm test` with dozens of parallel turbo tasks — so the ESM probe was observed failing at 5928ms on `execFileSync`. The failure is pure latency: the assertions only check which deps ended up in the child's require cache. The in-process sibling already carried an explicit 30s timeout. Hoisted that rationale into a single named `COLD_LOAD_TIMEOUT_MS` shared by all three cold-loading cases. Test-only; ships with an empty changeset (releases nothing).
1 parent 6169615 commit 2b1d031

2 files changed

Lines changed: 22 additions & 6 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
---
3+
4+
test(lint): give the lazy-deps dist probes the same cold-load timeout as their sibling (#3662)
5+
6+
The two dist probes in `lazy-deps.test.ts` spawn a child `node` that cold-loads
7+
sucrase (~1.5 MB) and typescript (~9 MB) to prove neither arrives at import time.
8+
That cold load alone exceeds vitest's default 5s timeout under a whole-repo
9+
`pnpm test` (dozens of parallel turbo tasks), so the ESM probe was observed
10+
failing at 5928ms on `execFileSync` — pure latency, not a contract failure. The
11+
in-process sibling already carried an explicit 30s timeout; hoisted that rationale
12+
into one named `COLD_LOAD_TIMEOUT_MS` shared by all three cold-loading cases.
13+
Test-only flake fix; releases nothing.

packages/lint/src/lazy-deps.test.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ const LAZY_DEPS = ['typescript', 'sucrase'];
3636
const depLoaded = (cache: Record<string, unknown> | undefined, dep: string) =>
3737
Object.keys(cache ?? {}).some((p) => p.split(/[/\\]/).join('/').includes(`/node_modules/${dep}/`));
3838

39+
// Every case below cold-loads sucrase + typescript (~1.5 MB / ~9 MB) — in-process
40+
// for the behavioral case, in a spawned child `node` for the dist probes. On a
41+
// loaded runner (dozens of parallel turbo tasks) that alone takes >5s, so vitest's
42+
// default 5s timeout flakes while the assertion set is pure contract, not latency.
43+
const COLD_LOAD_TIMEOUT_MS = 30_000;
44+
3945
describe('lazy dependency loading (kernel boot-path contract)', () => {
4046
it('no src file eagerly imports a lazy dep (import type only)', () => {
4147
// Static `import`/`export ... from '<dep>'` executes at module init in
@@ -85,7 +91,7 @@ describe('lazy dependency loading (kernel boot-path contract)', () => {
8591
{ encoding: 'utf8' },
8692
);
8793
expect(out).toContain('OK');
88-
});
94+
}, COLD_LOAD_TIMEOUT_MS);
8995

9096
it.skipIf(!existsSync(join(distDir, 'index.js')))('built ESM dist does not load a lazy dep until a react page is validated', () => {
9197
const out = execFileSync(
@@ -101,7 +107,7 @@ describe('lazy dependency loading (kernel boot-path contract)', () => {
101107
{ encoding: 'utf8' },
102108
);
103109
expect(out).toContain('OK');
104-
});
110+
}, COLD_LOAD_TIMEOUT_MS);
105111

106112
it('loads each dep lazily in-process and the gates still work', async () => {
107113
const req = createRequire(import.meta.url);
@@ -129,8 +135,5 @@ describe('lazy dependency loading (kernel boot-path contract)', () => {
129135
});
130136
expect(depLoaded(req.cache, 'typescript')).toBe(true);
131137
expect(props.some((f) => f.rule === 'react-prop-missing-required' && /objectName/.test(f.message))).toBe(true);
132-
// Cold-loading sucrase + typescript in-process takes >5s on a loaded CI
133-
// runner (dozens of parallel turbo tasks) — the default 5s timeout flakes
134-
// there while the assertion set is pure contract, not latency.
135-
}, 30_000);
138+
}, COLD_LOAD_TIMEOUT_MS);
136139
});

0 commit comments

Comments
 (0)