Skip to content

test: stop Vite reloading @zitadel/sdk-qwik's browser suite mid-run on a cold cache - #2569

Merged
fforootd merged 1 commit into
mainfrom
claude/affectionate-heisenberg-e9412b
Nov 1, 2026
Merged

fforootd merged 1 commit into
mainfrom
claude/affectionate-heisenberg-e9412b

Conversation

@fforootd

@fforootd fforootd commented Nov 1, 2026

Copy link
Copy Markdown
Member

Context

Summary

  • With a cold Vite cache, the browser project of @zitadel/sdk-qwik failed its first attempt every time. Vite's dependency scan compiles JSX with its own options, React's by default, and reads neither the tsconfig's jsxImportSource nor qwikVite. Every .tsx spec then imported react/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, liquidjs and lucide only as Chromium requested them. It reloaded the page twice, and src/index.spec.tsx failed 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.
  • The browser project now sets optimizeDeps.rolldownOptions.transform.jsx.importSource to @qwik.dev/core. qwikVite already excludes that package's jsx-dev-runtime from optimization. The scan now succeeds and pre-bundles every dependency before the first spec.
  • There is no optimizeDeps.include list. The late dependencies are imports of @zitadel/components and @zitadel/api-mock and 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/components needs 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/.vitest and node_modules/.vite were 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: moon run sdk-qwik:test --force, three runs. Each passes on attempt 1 with 157 tests and no optimizer or reload line.
  • After: vitest run --maxWorkers=3 under 300 and 450 perl busy loops passes on the first attempt.
  • moon run sdk-qwik:lint sdk-qwik:typecheck
  • vitest run --project browser in packages/components from a cold cache passes and optimizes nothing mid-run.

Release notes / changeset

  • No changeset required — no shipped behavior changed.

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 in dispatchUntilForwarded.
    • Both resuming a server-rendered login specs exceed 15 s, because each renderServerLogin call starts a new Vite server with qwikVite in 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

…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>
Copilot AI balanced review requested due to automatic review settings November 1, 2026 18:05
@vercel

vercel Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
cloud Ready Ready Preview Nov 1, 2026 6:09pm UTC

Request Review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review ✅ Completed 2026-11-01T18:07:24.621037Z 769d7c1 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@zitadel-kanban zitadel-kanban Bot moved this to Inbox in Engineering Kanban Nov 1, 2026
@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

⚠️ No Changeset found

Latest commit: 769d7c1

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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-qwik browser project 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 browser project only; the ssr project runs in node and the fix targets the browser dependency scan specifically.
  • @zitadel/components legitimately 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.md skip categories and the test: 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

@fforootd
fforootd added this pull request to the merge queue Nov 1, 2026
Merged via the queue into main with commit 2cc7076 Nov 1, 2026
23 checks passed
@fforootd
fforootd deleted the claude/affectionate-heisenberg-e9412b branch November 1, 2026 18:16
@github-project-automation github-project-automation Bot moved this from Inbox to Done in Engineering Kanban Nov 1, 2026

This branch was successfully deployed

1 active deployment
Preview — 769d7c1f Deployed Nov 1, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants