Skip to content

test: keep the SDK suites and the conformance lane clear of cold-start flakes - #3526

Merged
fforootd merged 3 commits into
mainfrom
claude/sdk-cold-render-test-budgets
Dec 1, 2026
Merged

fforootd merged 3 commits into
mainfrom
claude/sdk-cold-render-test-budgets

Conversation

@fforootd

@fforootd fforootd commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

Context

  • Refs: three intermittent full-pr failures on 2026-12-01 (runs 46709456301 / job 142864625436 and 46709428765 / job 142864535175, both green on the second attempt). No issue to close.

Summary

The three failures have three separate causes. Two share a pattern: a cold first-time load lands inside a tight default timeout.

  • @zitadel/sdk-solid keyed-project test ("shows the sign-in step for a project that carries a publishable key")
    • Cause: in Solid and Svelte this is the first test in its file that waits for a rendered step, so it pays the widget's cold first render (LiquidJS, the locale, the mock flow) inside testing-library's 1 s waitFor default. In React, Vue and Angular, 3–5 earlier tests warm it, and their copy runs in under 300 ms.
    • Evidence: CI passes of the Solid test run at a median of 632 ms, p90 1,077 ms, max 1,296 ms; the Svelte copy reaches 1,075 ms.
    • Seen only on the MCP stack's runs: 5 failures in 27 executions there, 0 in 80 elsewhere since feat: harden the SDK suites and await async widget callbacks #3448 (one-sided Fisher p ≈ 0.0008). The first failure (60f1752) changed no components, api-mock or sdk-solid code, so the stack's frontend code is not the cause. Stack runs execute more tasks at once, which may be why; that is not proven.
    • Fix: give that one waitFor 4 s, in sdk-solid and sdk-svelte. It stays inside Solid's 5 s per-test budget.
  • @zitadel/sdk-next first middleware case ("public route with no token continues as unauthenticated")
  • @zitadel/conformance-solid-start
    • Cause: the lane runs the SDKs linked from the workspace, so the Vite dev server discovers the widget's dependencies only when a browser first visits, then re-bundles them and reloads the page mid-test. On a slow runner the first attempt timed out. Closing that page aborted a pending request, and Vite 8.3.8 buffers an error raised while no page is connected and replays it to the next page as its overlay. That next page is the retry's, so the overlay blocked its clicks and retries: 1 could not absorb the failure.
    • Evidence: 18 single-try failures Nov 15–30 (including nightly main), then 2 double failures after retries were added (feat: add a user hook to every UI SDK #3492 and feat(api): keep an OAuth client connected with refresh tokens, and serve clients that hold no secret #3495). The reload happened in every execution of the SolidStart and TanStack Start lanes. The replayed overlay was reproduced in isolation on 8.3.8.
    • Fix: a shared Playwright globalSetup (conformance/suite/src/warm-up.ts, wired in suite/src/config.ts). It loads /login before the first test, tracks every request and main-frame navigation from before the first load, and closes the page only after a full 10 s with no request in flight and no navigation. If 180 s cannot fit one such window it fails, naming the open requests. Event streams (TanStack Start's dev-tools console pipe, for one) stay open for the page's life and do not count. Playwright starts webServer before globalSetup, and withZitadel() returns only webServer, so the two do not collide.
    • Also corrects the retries comment in suite/src/config.ts and the line in conformance/AGENTS.md.

Validation

  • vitest run --project browser src/__tests__/index.test.tsx (sdk-solid, 89 passed); vitest run --project browser src/__tests__/index.test.ts (sdk-svelte, 93 passed); vitest run (sdk-next, 277 passed).
  • sdk-next first case locally: 122–145 ms before the change, 5–6 ms after.
  • turbo run lint typecheck for sdk-next, sdk-solid, sdk-svelte and @zitadel/conformance: pass.
  • pnpm run conformance in conformance/fixtures/solid-start, with node_modules/.vite removed each time: 4/4 pass. Vite's "optimized dependencies changed. reloading" line always comes before "[conformance] warm-up: /login settled", and nothing re-optimizes, reloads or reports an internal server error after "Running 1 test". The test takes about 3 s (7.4 s before).
  • Same, pinned to one core with 3 busy loops: 2/2 pass, reload inside the warm-up, test 11.6–12.9 s (about 25 s before).
  • TanStack Start, 2/2 cold, reload inside the warm-up; React and Next.js lanes, 1/1 each.
  • full-pr on 7e6a62e (the first version of the warm-up): green. All twelve conformance lanes logged "warm-up: /login settled", in 11–15 s each.
  • After the review fix (d1e3bf4, requests tracked and the window never shortened): lint and typecheck for @zitadel/conformance; six cold lane runs, all pass (TanStack Start ×2, SolidStart ×2, React, Next.js). In every Vite run the only "optimized dependencies changed. reloading" line comes before the settled line (12–14 s), with no internal server error and nothing after "Running 1 test".
  • full-pr on d1e3bf4: green, 87 of 87 tasks. All twelve conformance lanes logged "warm-up: /login settled", in 10–15 s each, so no lane keeps an ordinary request open for the page's life.
  • node scripts/check-pr-title.mjs --title "test: keep the SDK suites and the conformance lane clear of cold-start flakes": ok.
  • Not verified:
    • The other eight conformance lanes (Angular, Nuxt, Qwik, Qwik Router, Solid, Svelte, SvelteKit, Vue) were not run locally with the warm-up; the two CI runs above are their only runs.
    • The original Solid waitFor timeout and the 15 s conformance timeout could not be reproduced locally, so the fixes rest on the CI timings and the mechanism above.

Release notes / changeset

  • No changeset required — no shipped behavior changed.

Notes

  • Follow-up (product, not in this PR): real SolidStart and TanStack Start apps may still see the first-visit reload in vite dev. A fix there would need the dev server to pre-bundle the widget's dependencies at startup, as packages/sdk-nuxt/src/module.ts does for Nuxt. That means an SDK Vite plugin or a CLI change, since the CLI leaves vite.config alone.
  • The warm-up adds 11–25 s to each conformance lane locally, 11–15 s on CI's first run.
  • Unrelated noise: the MSW "unhandled request … liquidjs.js" lines in the SDK browser suites come from the mock's passthrough pattern not matching /.vitest/…/deps/ paths. They don't fail anything.

https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U


Generated by Claude Code

The Solid and Svelte keyed-project tests are the first in their files to
wait for a rendered step, so they pay the widget's cold first render
(LiquidJS, locale, mock flow) inside waitFor's 1 s default; CI runs reach
1.3 s. Give that wait 4 s, inside Solid's 5 s per-test budget.

sdk-next's middleware adapter imported ../auth.js inside the first test,
which carried the cold module load (CI median 1.8 s, max 4.6 s against
5 s). Import it statically: the file never resets modules and vi.mock is
hoisted, so behaviour is unchanged and the first case drops to ~5 ms.

No changeset required — no shipped behavior changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmRkyq5frfEBq7svZeP
… test

A fixture runs the SDKs linked from the workspace, so its Vite dev server
only discovers the widget's dependencies when a browser first imports
them, pre-bundles them and reloads the page. That reload landed inside
the test; on a slow runner the first attempt timed out, closing the page
aborted a pending request, and Vite replayed that error as its overlay
on the retry's fresh page, so `retries: 1` could not absorb it.

A global setup now loads /login before the first test and waits until
the page keeps one document, idle, for 10 s, then closes it with no
request in flight. Correct the comment and the AGENTS.md line that said
the retry covers the reload.

No changeset required — no shipped behavior changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmRkyq5frfEBq7svZeP
Copilot AI balanced review requested due to automatic review settings December 1, 2026 19:37
@vercel

vercel Bot commented Dec 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 Dec 1, 2026 7:55pm UTC

Request Review

@chatgpt-codex-connector

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

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
🔒 Security Review ✅ Completed 2026-12-01T19:41:25.732943Z 7e6a62e 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.

@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ No Changeset found

Latest commit: d1e3bf4

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.

🟡 Changes recommended

The warm-up can close the page while requests are still pending and treat an incomplete quiet window as success, leaving the dev server unsettled for tests.

2 open issues
What changed in this PR

This PR targets cold-start flakes in the SDK tests and shared conformance lane without changing shipped SDK behavior.

Changes:

  • Extends the first rendered-step wait in Solid and Svelte to four seconds.
  • Moves the Next.js middleware test’s auth import outside test execution.
  • Adds a shared browser warm-up before conformance tests and updates retry guidance.
File Description
packages/​sdk-svelte/​src/​__tests__/​index.test.ts Allows more time for the widget’s first render.
packages/​sdk-solid/​src/​__tests__/​index.test.tsx Allows more time for the widget’s first render.
packages/​sdk-next/​src/​__tests__/​middleware.test.ts Imports auth statically to avoid cold loading during the first test.
conformance/​suite/​src/​warm-up.ts Adds a login-page warm-up to absorb dev-server reloads.
conformance/​suite/​src/​config.ts Registers the warm-up and clarifies the retries comment.
conformance/​AGENTS.md Updates guidance on warm-up and retry responsibilities.

Review effort: Balanced

Comment thread conformance/suite/src/warm-up.ts Resolved
Comment thread conformance/suite/src/warm-up.ts Resolved
The warm-up watched only navigations in its quiet window, so a request
started in it could still be pending when the page closed, and near the
end of the budget a shortened window counted as settled. Track every
request from before the first load, restart the window on any request or
main-frame navigation, close only with none in flight after a full 10 s,
and fail naming the open requests when the budget cannot fit one. Event
streams, such as TanStack Start's dev-tools console pipe, stay open for
the page's life and do not count.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmRkyq5frfEBq7svZeP
@fforootd
fforootd added this pull request to the merge queue Dec 1, 2026
Merged via the queue into main with commit 2847d1a Dec 1, 2026
19 checks passed
@fforootd
fforootd deleted the claude/sdk-cold-render-test-budgets branch December 1, 2026 20:24
@github-project-automation github-project-automation Bot moved this from Inbox to Done in Engineering Kanban Dec 1, 2026

This branch was successfully deployed

1 active deployment
Preview — d1e3bf49 Deployed Dec 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

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants