Repository navigation
test: load @zitadel/sdk-qwik's server build once and lengthen its listener deadline - #2571
Conversation
…tener deadline The resume specs started a worker, a Vite server and Qwik's server build for every server render, inside each test's 15 s budget: 9.5-12.3 s of it at 450 busy loops, and a timeout on CI. One worker now loads the build in the describe block's beforeAll, whose 60 s budget only bounds a hang, renders every request, and is stopped in afterAll. dispatchUntilForwarded's 1 s deadline was shorter than the first visible task and spec segment take on a loaded runner. It is now 10 s, under the 15 s test timeout, so a listener that never attaches still fails with its own message. 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 thoroughly examined the worker protocol, shared-build lifecycle, command registration, deadline change, and import removal, and surfaced no objective defects or unresolved concerns warranting PR comments.
No open issues 🎉
What changed in this PR
This PR hardens the @zitadel/sdk-qwik browser test suite against slow/loaded CI runners. Previously, renderServerLogin spun up a fresh Vite+Qwik worker and ran ssrLoadModule on every server-render call, so each test paid ~10s of server-build cost inside its own 15s budget — causing the resuming a server-rendered login specs to time out and the empty-proxyPath spec to miss a tight 1s listener deadline. The change loads the Qwik server build once in a reused worker and renders each request over a MessageChannel, and lengthens the dispatchUntilForwarded deadline to 10s (still under the 15s test timeout). This mirrors the pattern established for sdk-svelte (#2496) and sdk-solid (#2497). No shipped behavior changes, so no changeset is required (consistent with the changeset decision table).
Changes:
- Reworked the server-markup worker to compile the build once and serve renders per incoming message, with new
loadServerLogin/closeServerLoginlifecycle commands and a reused,unref()ed worker. resuming a server-rendered loginnow loads the build inbeforeAll(60s budget) and tears it down inafterAll, so each test's budget covers only render + resume.- Raised
dispatchUntilForwarded's deadline from 1000ms to 10_000ms and updated the surrounding comments/error message.
| File | Description |
|---|---|
packages/sdk-qwik/vitest.config.ts |
Registers the new loadServerLogin/closeServerLogin browser commands alongside renderServerLogin. |
packages/sdk-qwik/src/index.spec.tsx |
Loads the server build once via beforeAll/afterAll, scopes serverMarkup to the resume block, and widens the listener deadline to 10s with updated comments. |
packages/sdk-qwik/src/browser-commands.d.ts |
Declares the two new browser command signatures. |
packages/sdk-qwik/src/__tests__/server-markup.worker.mjs |
Loads the Qwik server build once, closes the Vite server, then renders per message over the transferred reply port. |
packages/sdk-qwik/src/__tests__/server-markup.ts |
Adds a cached shared-worker loader plus loadServerLogin/renderServerLogin/closeServerLogin using MessageChannel, with graceful close/error handling. |
packages/sdk-qwik/src/__tests__/resume-server-markup.ts |
Exposes loadServerMarkup/closeServerMarkup wrappers around the new commands. |
Review effort: Balanced
Context
gate-turborun failed@zitadel/sdk-qwik#teston all four attemptsSummary
Attempts 2–4 of that run had a warm cache and no optimizer activity. They failed on load, in three specs of
src/index.spec.tsx:ZitadelLogin > binds an empty proxyPath as the origin root, matching its attribute:listener for "zitadel-flow-step" never forwarded within 1000ms, all three attempts (2042–2952 ms with the failure screenshot).resuming a server-rendered login > starts its first flow with the purpose the server renderedand> loads the supplied flow on its first request instead of creating one:Test timed out in 15000msfive times, and one pass at 14737 ms.Cause 1: every server render rebuilt Qwik's server build
renderServerLogin(src/__tests__/server-markup.ts) started a new worker per call. The worker started a new Vite server and ranssrLoadModuleonserver-login.tsx: 28 modules and about 7 MB of transformed code, over 4 MB of it Qwik's dev core.Each test paid that inside its own 15 s budget. Probes in the worker split one call:
createServerssrLoadModuleSo this is load on the server build, not a slow resume. On
mainat 450 loops the two tests took 9.5–12.3 s of their 15 s; at 700 loops one timed out.Cause 2: a fixed 1 s deadline on a wait that takes seconds under load
dispatchUntilForwardedre-dispatches an event until the wrapper'suseVisibleTask$has wired its listener and the spec's$()callback has run. Under Vitest's dev server, qwikVite uses thesegmententry strategy, so that first call also fetches the callback's module. On a busy main thread the task itself runs late.Only
ZitadelLogin's copy failed. It is the file's first spec to wait on a visible task. Its Logout and Session twins took 175–398 ms in the same attempts.Busy loops barely slow Chromium on this machine: the spec took under 0.25 s at 450 loops. Throttling Chromium's CPU through CDP does slow it, and at 30× and 40×
mainfails exactly as CI did: only this spec,never forwarded within 1000ms, at 2555 and 2974 ms. With the deadline lifted, the wait took:expect.pollspecs fail tooAt 30–40× the rest of the file takes 10–12 s; in CI's attempts it took 10–18 s. So CI's browser ran at roughly that speed, and 120× is several times slower.
Fix
loadServerLogin,renderServerLoginandcloseServerLogincommands. As in the svelte and solid specs, the worker closes its Vite server after loading, and the loaded module keeps rendering. The markup is unchanged: the old and the new worker render byte for byte the same HTML, apart from Qwik's random per-render instance id.resuming a server-rendered loginloads the build inbeforeAlland stops the worker inafterAll. The hook gets a 60 s budget, which only bounds a hang; the load took 9.7–11.2 s at 450 loops and 13.4–16.5 s at 700. The tests' 15 s timeout stays, and their bodies are unchanged: they stillawait serverMarkup(props), which is now one fast round trip.unref()ed, so a run that never reachesafterAllcan still exit. With neitherunref()nor the close, Vitest waits out itsclose timed out after 10000ms.dispatchUntilForwardedallows 10 s. That is above the 5.2 s the wait took at the slowest throttle at which the rest of the file still passes. It is also under the 15 s test timeout, so a listener that never attaches still fails with its own message.This is the pattern #2496 and #2497 used for sdk-svelte and sdk-solid.
Validation
Local loaded runs
vitest run --maxWorkers=3inpackages/sdk-qwik, beside Nperl -e 'while(1){}'busy loops killed afterwards. The.vitestdeps cache was warm, as in CI's failing attempts.Emulation.setCPUThrottlingRate). The hook's load times come from a temporary log line inbeforeAll. Neither is part of this PR.proxyPath(Login)mainmainTest timed out in 15000ms, 14874 msmainnever forwarded within 1000msWith #2569, from a cold cache
.vitestandnode_modules/.viteremoved before each run, 450 loops: 157/157 on the first attempt, 2/2 runs. The resume tests took 14–249 ms and 54–66 ms.moon run sdk-qwik:test --force, cold, idle: passes on attempt 1, 157 tests.Deterministic stand-ins (idle)
vitest run --testTimeout=300: onmainboth resume tests time out; this PR passes 157/157, 2/2 runs.mainthe empty-proxyPathspec fails (never forwarded within 1000ms); this PR passes 157/157, 2/2 runs, that spec at 1371–1497 ms.Mutation checks (this PR)
purposefromloginAttrs: "starts its first flow…" fails (expected { project_id: 'proj-global', …(1) } to match object { purpose: 'register' }).resume-flow-id: "loads the supplied flow…" fails (expected null to be 'flow_123').zitadel-flow-steplistener: the empty-proxyPathspec fails at 10106 ms withlistener for "zitadel-flow-step" never forwarded within 10000ms, its own message, not the test timeout.Other checks
corepack pnpm run typecheckinpackages/sdk-qwik: 0 errors.biome check packages/sdk-qwik: clean.vitest runidle: 157 passed; the resume tests take 11–12 ms and 53–54 ms, against about 470 ms onmain.node scripts/check-changesets-status.mjs --pending --summary, as CI runs it: ok.node scripts/check-pr-title.mjs --title "…": ok.No
gh workflow run ci-turbo.ymldispatch was run for this branch.Release notes / changeset
No changeset required — no shipped behavior changed.
Notes
.github/semantic.ymlhas nosdk-qwikscope, so the title has no scope.check-changesets-status.mjs --base origin/mainreportsfailed: its test-file pattern does not matchvitest.config.tsorsrc/browser-commands.d.ts. Neither ships (files: ["dist"]), and test: stop Vite reloading @zitadel/sdk-qwik's browser suite mid-run on a cold cache #2569 merged avitest.config.ts-only change without a changeset.expect.poll,vi.waitFor) held up to 120× throttling, so this PR leaves them alone.🤖 Generated with Claude Code