Skip to content

Commit aa3c761

Browse files
schmugclaude
andauthored
fix(e2e): stabilize playwright against Vite dep-optimizer races (#38)
The desktop golden-path e2e intermittently failed in CI with "504 Outdated Optimize Dep" on the dynamic import of OSShell.tsx. Vite's dep optimizer was re-bundling mid-flight as it discovered deps reached only through lazy-loaded islands (zustand, zustand/middleware, react-rnd), invalidating in-flight module URLs. - astro.config.mjs: pre-bundle the offending deps via optimizeDeps.include and warm up the island entries with server.warmup.clientFiles so Vite's crawl completes before the first request. - playwright.config.ts: in CI, serve the built site via astro preview — no dev optimizer at all, closest to prod. Local dev keeps astro dev for fast iteration. Verified: 5/5 cold-cache runs pass in CI mode, 5/5 in local dev mode. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 9f06528 commit aa3c761

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

‎astro.config.mjs‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,23 @@ export default defineConfig({
1212
trailingSlash: 'ignore',
1313
vite: {
1414
plugins: [tailwindcss()],
15+
// Pre-bundle deps reached only through lazy-loaded islands (OSShell, MobileShell).
16+
// Without this, Vite discovers them on first page load and re-optimizes mid-flight,
17+
// returning 504 "Outdated Optimize Dep" on in-flight dynamic imports and flaking e2e.
18+
optimizeDeps: {
19+
include: ['zustand', 'zustand/middleware', 'react-rnd'],
20+
},
21+
// Warm up the lazy island entries so Vite's dep crawl completes before the
22+
// first browser request — complements optimizeDeps.include above.
23+
server: {
24+
warmup: {
25+
clientFiles: [
26+
'./src/components/RootShell.tsx',
27+
'./src/components/os/OSShell.tsx',
28+
'./src/components/mobile/MobileShell.tsx',
29+
],
30+
},
31+
},
1532
},
1633

1734
integrations: [

‎playwright.config.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,14 @@ export default defineConfig({
1212
screenshot: 'only-on-failure',
1313
},
1414
webServer: {
15-
command: 'npm run dev',
15+
// In CI, serve the built site via `astro preview` — no Vite dep optimizer,
16+
// so no "504 Outdated Optimize Dep" races on in-flight dynamic islands.
17+
// Locally, keep `astro dev` for fast iteration; `optimizeDeps.include` in
18+
// astro.config.mjs softens the same race for dev runs.
19+
command: process.env.CI ? 'npm run build && npm run preview' : 'npm run dev',
1620
url: 'http://localhost:4321',
1721
reuseExistingServer: !process.env.CI,
18-
timeout: 60_000,
22+
timeout: process.env.CI ? 120_000 : 60_000,
1923
},
2024
projects: [{ name: 'chromium', use: { ...devices['Desktop Chrome'] } }],
2125
});

0 commit comments

Comments
 (0)