Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .changeset/lazy-deps-dist-probe-timeout.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
---
---

test(lint): give the lazy-deps dist probes the same cold-load timeout as their sibling (#3662)

The two dist probes in `lazy-deps.test.ts` spawn a child `node` that cold-loads
sucrase (~1.5 MB) and typescript (~9 MB) to prove neither arrives at import time.
That cold load alone exceeds vitest's default 5s timeout under a whole-repo
`pnpm test` (dozens of parallel turbo tasks), so the ESM probe was observed
failing at 5928ms on `execFileSync` — pure latency, not a contract failure. The
in-process sibling already carried an explicit 30s timeout; hoisted that rationale
into one named `COLD_LOAD_TIMEOUT_MS` shared by all three cold-loading cases.
Test-only flake fix; releases nothing.
15 changes: 9 additions & 6 deletions packages/lint/src/lazy-deps.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -36,6 +36,12 @@ const LAZY_DEPS = ['typescript', 'sucrase'];
const depLoaded = (cache: Record<string, unknown> | undefined, dep: string) =>
Object.keys(cache ?? {}).some((p) => p.split(/[/\\]/).join('/').includes(`/node_modules/${dep}/`));

// Every case below cold-loads sucrase + typescript (~1.5 MB / ~9 MB) — in-process
// for the behavioral case, in a spawned child `node` for the dist probes. On a
// loaded runner (dozens of parallel turbo tasks) that alone takes >5s, so vitest's
// default 5s timeout flakes while the assertion set is pure contract, not latency.
const COLD_LOAD_TIMEOUT_MS = 30_000;

describe('lazy dependency loading (kernel boot-path contract)', () => {
it('no src file eagerly imports a lazy dep (import type only)', () => {
// Static `import`/`export ... from '<dep>'` executes at module init in
Expand DownExpand Up@@ -85,7 +91,7 @@ describe('lazy dependency loading (kernel boot-path contract)', () => {
{ encoding: 'utf8' },
);
expect(out).toContain('OK');
});
}, COLD_LOAD_TIMEOUT_MS);

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

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