Skip to content

Re-enable storybook browser tests in CI (SKIP_STORYBOOK_TESTS since 7544f31) #35

Closed

Description

@omridevk

Problem

All storybook browser suites are skipped in CI via SKIP_STORYBOOK_TESTS: '1' (ci.yml:55), gated per-package in vitest.config.ts (process.env.SKIP_STORYBOOK_TESTS ? [] : [storybook]). They "run locally" — in practice nobody does, so story tests rot silently.

Consequence (proven on PR #33)

Two stories were red on main for an unknown period: page-action-card Errored (real UX bug — JSON-quoted error text) and file-read-card Read (asserted text Pierre renders into an open shadow root). Both only surfaced during a local full-suite run.

History (commit 7544f31, 2026-06-19)

Root cause then: "upstream vitest/storybook cold dep-optimize reload race that fails only on CI's constrained runners (reproduced in a 2-core Linux container; passes on a warm cache / unconstrained CPU)".

Dead-ends already tried and reverted (don't repeat): per-package browser ports, react devDeps, optimizeDeps include/exclude/noDiscovery, addon removal, a serial-test step.

New data (2026-07-06, PR #33)

The same suites flaked locally under full turbo parallelism (browser-session connect timeouts, Cannot read properties of undefined (reading 'map'), failures hopping between solid-diffs / ui-kit-system / ui-kit-tap per run) and were cured completely by turbo --concurrency=3 (root pnpm test now caps it). CI's turbo invocation has NO concurrency cap on a ~4-vCPU runner — contention plus the cold optimizer compound there.

Leads

  1. Cheapest: add --concurrency=2/3 to the ci.yml turbo run and drop SKIP_STORYBOOK_TESTS — the local result suggests contention is the dominant factor. Validate by re-running the CI job several times on a scratch PR.
  2. If the cold-optimize race persists: warm the vite/storybook dep-optimizer cache in a prior CI step (the sb-vitest deps dir under node_modules/.cache/storybook), or check whether the storybook 10.x / vitest 4.1.9 pairing (post-Harness-testkit adoption repo-wide: no hand-rolled waits, 5 latent bugs fixed, stable pnpm test #33 versions are aligned) already fixed the upstream race.
  3. Keep the SKIP_STORYBOOK_TESTS escape hatch in the configs either way.

Related: the extensions-filter gap issue (same PR-#33 findings, same ci.yml line).

🤖 Generated with Claude Code

Activity

  1. added 2 commits that reference this issue on Jul 6, 2026
    eb820f3
    371f867
  2. omridevk commented on Jul 6, 2026

    @omridevk
    ContributorAuthor

    Tried the cheap fix (lead #1) on branch ci/test-gate-extensions-and-storybook / PR #36: dropped SKIP_STORYBOOK_TESTS and relied on --concurrency=3. It does not hold on CI — ruled out.

    Two build + test runs, both failed on the documented cold vite dep-optimizer race:

    • Run 1 (10m21s): packages/widget/src/page/page-mirror.stories.tsx — Agent Click + Showcase, Test timed out in 15000ms, preceded by Failed to resolve dependency: react … present in client 'optimizeDeps.include' and TypeError: Cannot read properties of undefined (reading 'map').
    • Run 2 (4m9s): packages/widget/src/presence.stories.tsx > Default — same 15s timeout, same optimizer errors.

    The failing suite hops between runs (page-mirror → presence) — matches the "failures hopping between packages" signature. --concurrency=3 cured this locally under full turbo parallelism but not on the ~4-vCPU runner.

    Escape hatch (SKIP_STORYBOOK_TESTS) restored and stays. Issue remains open for lead #2 — warm the vite/storybook dep-optimizer cache in a prior CI step (node_modules/.cache/storybook), or confirm whether the storybook 10.x / vitest 4.1.9 pairing fixed the upstream race.

  3. omridevk commented on Jul 7, 2026

    @omridevk
    ContributorAuthor

    Resolved by #37 (merged, squash ac27929). Storybook browser suites now run in CI — SKIP_STORYBOOK_TESTS is gone.

    Root cause (reproduced in a CPU-throttled 2-core container)

    Cold vite dep-optimizer reloads the browser page under contention, so an interaction story loads/reloads mid-test:

    • Intra-package: many story files run in parallel browser workers sharing one cold optimizer → a worker mid-play() gets reloaded → 15s timeout. Consistently ui-kit-system/presence.stories > Default on CI (it has the longest play(), so it's the most-exposed victim).
    • Cross-package: many packages' optimizers starve each other → a package's page is closed during file setup (createTesters) → "Browser connection was closed". Seen on ui-kit-chat/action-bar.stories.

    Same upstream bug as storybookjs/storybook#33091 (preview-annotation files not registered as vite optimizer entries); fixed upstream by storybookjs/storybook#33875, shipping in storybook 10.5.0 (not in the 10.4.x line).

    Fix (both parts load-bearing, proven by experiment)

    • fileParallelism: false on the 7 storybook vitest projects → intra-package.
    • --concurrency=3 on the turbo test run → cross-package.

    Ruled out by experiment (all still failed the reproducing baseline)

    • Warm the optimizer cache (this issue's lead chore: version packages (0.0.2) #1/fix(plugin): mount the widget on SSR stacks via the module graph #2) — vite re-optimizes every run ("config changed"), so warming is discarded.
    • Remove @storybook/addon-docs / react — red herring.
    • Upgrade storybook 10.4.4 → 10.4.6 — #33875 isn't in the 10.4.x line.
    • optimizeDeps.include (real harness deps) and optimizeDeps.entries — 5-6/6 fail; the failure is optimize timing under contention, not late dep discovery.
    • test.retry — would work (one-time cold reload) but masks genuine flakes; not adopted.

    Follow-up

    When storybook 10.5.0 is stable, upgrade and drop both mitigations (the cap slows CI and serial story files are slower). Tracking that here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions