Skip to content

host: Change tests to serve test realm fetches in-page - #5717

Open
backspace wants to merge 1 commit into
mainfrom
test-realm-fetch-cs-12406
Open

host: Change tests to serve test realm fetches in-page#5717
backspace wants to merge 1 commit into
mainfrom
test-realm-fetch-cs-12406

Conversation

@backspace

@backspace backspace commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

As the host test suite gets faster, there’s a race condition that has been increasing instability: the test-realm service worker can only intercept requests once it’s been set up and activated, so Failed to fetch happens with the RETRY_PATTERN until it comes up. In #5653, where I experimented with bundling @cardstack/base instead of as a realm, the Failed to fetch went from ≈400/run to ≈2500/run.

This serves test realm directly instead of through a service worker. The tests that work with img, audio, video etc do exercise the service worker so this test-only override doesn’t mean the worker has no test coverage.

…rker

Host tests serve http://test-realm/* URLs through a service worker that
relays them to the in-browser mock realm. The worker only intercepts
once it controls the page and its per-module activation has been acked,
so a fetch issued before that window closes escapes to the real network
and fails — test-realm is not a real host. When the fetch is
fire-and-forget (a card component loading a realm's _types summary as
it renders), the rejection surfaces as a QUnit global error and fails
the whole shard rather than a single test.

The test fetch wrapper now answers requests whose URL falls under a
registered test realm via realm.maybeHandle. The registry is populated
at realm construction, before any component can render, so this path
has no startup window. A request the realm declines still falls through
to the network, and non-fetch resources (images, workers) continue to
rely on the service worker.

Module-loading latency normally hides the race: base card modules are
fetched and transpiled before their components can render, which takes
long enough that the worker is ready. Anything that shortens that path
re-exposes it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Preview deployments

Host Test Results

    1 files      1 suites   2h 54m 28s ⏱️
3 882 tests 3 868 ✅ 14 💤 0 ❌
3 901 runs  3 887 ✅ 14 💤 0 ❌

Results for commit 3040758.

Realm Server Test Results

    1 files      1 suites   14m 21s ⏱️
2 086 tests 2 086 ✅ 0 💤 0 ❌
2 165 runs  2 165 ✅ 0 💤 0 ❌

Results for commit 3040758.

@backspace backspace changed the title host: Change tests to answer test realm fetches in-page vs via worker host: Change tests to serve test realm fetches in-page Aug 7, 2026
@backspace
backspace marked this pull request as ready for review August 7, 2026 22:59
@backspace
backspace requested a review from a team August 7, 2026 23:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant