Repository navigation
test: stop Vite reloading @zitadel/sdk-qwik's browser suite mid-run on a cold cache - #2569
Conversation
…n a cold cache
Vite's dependency scan compiles each spec's JSX with its own options,
React's unless `optimizeDeps.rolldownOptions.transform.jsx` says
otherwise; neither the tsconfig's `jsxImportSource` nor qwikVite reaches
it. Every `.tsx` spec then imports `react/jsx-dev-runtime`, which does
not resolve, so the scan fails ("Failed to run dependency scan. Skipping
dependency pre-bundling.") and Vite finds @faker-js/faker and xstate, then
lit, dompurify, liquidjs and lucide only as Chromium requests them. It
reloads the page twice under src/index.spec.tsx, whose import then fails
("Failed to fetch dynamically imported module"). Every run with a cold
cache, as in CI whenever turbo misses, failed its first attempt this way
and passed only on a retry.
Point the scan's JSX at @qwik.dev/core, whose jsx-dev-runtime is already
in qwikVite's optimizeDeps.exclude. The scan then succeeds and pre-bundles
every dependency before the first spec runs. This replaces adding the late
dependencies to optimizeDeps.include: they are imports of
@zitadel/components and @zitadel/api-mock, so the list would have to name
them nested under those packages and follow their imports.
packages/components needs no change: its browser specs are .ts, its scan
succeeds, and a cold run optimizes nothing mid-run.
Evidence, cold cache = packages/sdk-qwik/.vitest and node_modules/.vite
removed before each run:
- before: `moon run sdk-qwik:test --force` fails attempt 1 (the scan error,
two reloads, index.spec.tsx not imported) and passes attempt 2/4.
- after, three runs: attempt 1 passes, 157 tests, no optimizer or reload
line.
- after, `vitest run --maxWorkers=3` under 300 and 450 busy loops: passes
first time; the two server-render specs take 7-11 s of their 15 s.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
There was a problem hiding this comment.
🟢 Approval recommended
The reviewer surfaced no unresolved defects or objections against this narrowly scoped test-config change, leaving nothing outstanding to block approval.
No open issues 🎉
What changed in this PR
This PR fixes a cold-cache flake in @zitadel/sdk-qwik's Vitest browser suite. On a cold Vite cache, Vite's dependency scan compiled JSX with React's defaults (ignoring the tsconfig jsxImportSource and qwikVite), so every .tsx spec tried to import the unresolvable react/jsx-dev-runtime. The scan then aborted pre-bundling, and Vite discovered dependencies (@faker-js/faker, xstate, lit, dompurify, liquidjs, lucide) lazily, reloading Chromium mid-run and causing src/index.spec.tsx to fail to load on the first attempt. This instability contributes to the flaky full-pr CI tracked in #1490.
The fix tells the dependency scanner to transform JSX with @qwik.dev/core as the import source (via optimizeDeps.rolldownOptions.transform.jsx.importSource), matching the package's tsconfig.lib.json jsxImportSource. Since qwikVite already excludes that package's jsx-dev-runtime from optimization, the scan succeeds and all dependencies are pre-bundled before the first spec runs.
Changes:
- Add
optimizeDeps.rolldownOptions.transform.jsx.importSource = "@qwik.dev/core"to the sdk-qwikbrowserproject so the cold-cache dependency scan resolves Qwik's JSX dev runtime instead of React's. - Add an explanatory comment documenting why the override is needed.
Notes confirmed during review:
- The override is correctly scoped to the
browserproject only; thessrproject runs in node and the fix targets the browser dependency scan specifically. @zitadel/componentslegitimately needs no equivalent change because its browser specs are.ts(no JSX scan failure).- No changeset is required: the change is exclusively a test config file, which matches the
.changeset/README.mdskip categories and thetest:PR title type.
| File | Description |
|---|---|
packages/sdk-qwik/vitest.config.ts |
Sets the browser project's dependency-scan JSX import source to @qwik.dev/core so a cold-cache scan resolves and pre-bundles all deps before the first spec, preventing mid-run Chromium reloads; adds a clarifying comment. |
Review effort: Balanced
Context
gate-turborun failed@zitadel/sdk-qwik#teston all four attemptsSummary
@zitadel/sdk-qwikfailed its first attempt every time. Vite's dependency scan compiles JSX with its own options, React's by default, and reads neither the tsconfig'sjsxImportSourcenorqwikVite. Every.tsxspec then importedreact/jsx-dev-runtime, which does not resolve, so the scan gave up:(!) Failed to run dependency scan. Skipping dependency pre-bundling.Vite then discovered@faker-js/faker,xstate,lit,dompurify,liquidjsandlucideonly as Chromium requested them. It reloaded the page twice, andsrc/index.spec.tsxfailed to import (Failed to fetch dynamically imported module). A retry passed only because attempt 1 had left the deps cache warm. CI runs cold whenever turbo misses the task, for example on any OpenAPI change.optimizeDeps.rolldownOptions.transform.jsx.importSourceto@qwik.dev/core.qwikVitealready excludes that package'sjsx-dev-runtimefrom optimization. The scan now succeeds and pre-bundles every dependency before the first spec.optimizeDeps.includelist. The late dependencies are imports of@zitadel/componentsand@zitadel/api-mockand do not resolve from this package, so such a list would have to name them nested (@zitadel/components > lit) and follow those packages' imports.@zitadel/componentsneeds no change. Its browser specs are.ts, so its scan succeeds, and a cold run optimizes nothing mid-run.Validation
A cold cache means
packages/sdk-qwik/.vitestandnode_modules/.vitewere removed before each run.moon run sdk-qwik:test --forcefails attempt 1 (the scan error, two reloads,index.spec.tsxnot imported) and passes attempt 2/4.moon run sdk-qwik:test --force, three runs. Each passes on attempt 1 with 157 tests and no optimizer or reload line.vitest run --maxWorkers=3under 300 and 450perlbusy loops passes on the first attempt.moon run sdk-qwik:lint sdk-qwik:typecheckvitest run --project browserinpackages/componentsfrom a cold cache passes and optimizes nothing mid-run.Release notes / changeset
Notes
This fixes the first attempt only. In feat: show project usage and keep core cloud identity free #2558's run the retries had a warm cache and no optimizer activity, and failed on load instead:
ZitadelLogin > binds an empty proxyPath…misses the 1000 ms deadline indispatchUntilForwarded.resuming a server-rendered loginspecs exceed 15 s, because eachrenderServerLogincall starts a new Vite server withqwikVitein a worker.Locally, under 450 busy loops, those two specs take 10–11 s of their 15 s, and CI ran at about twice that load. Hardening them is a separate change.
🤖 Generated with Claude Code