Skip to content

fix: decouple build + e2e from a live backend (staging)#225

Merged
senamakel merged 2 commits into
tinyhumansai:mainfrom
senamakel:fix/decouple-build-e2e-from-staging
Jul 5, 2026
Merged

fix: decouple build + e2e from a live backend (staging)#225
senamakel merged 2 commits into
tinyhumansai:mainfrom
senamakel:fix/decouple-build-e2e-from-staging

Conversation

@senamakel

Copy link
Copy Markdown
Member

Problem

next build prerenders app/sitemap.ts, which reads the directory from the API base. It used the default SDK client (30s timeout × 3 retries ≈ 90s), so a slow or down backend hung the build past Next's per-route timeout and failed it. Both the Build and E2E CI jobs run next build first, so a staging outage (e.g. a 502) failed them even though nothing about a PR touched staging — the exact failure that blocked #223.

Separately, every Playwright spec is gated behind E2E_LIVE/E2E_X402/API_URL and skips in CI, so the E2E job never actually exercised the app against a (mocked) backend — its only real work was the build.

Changes

1. Bound the build-time directory fetch

  • New createReadOnlyClient() in website/src/common/api-client.ts: unauthenticated, no retries, 8s timeout, for build-time/crawler reads. The existing try/catch in sitemap.ts still degrades to static routes on failure — this only caps how long an outage may block the build.
  • CI Build job builds with NEXT_PUBLIC_API_BASE_URL pointed at an unreachable sentinel (http://127.0.0.1:9999), so the build provably never contacts staging (reads fail fast → static output).

2. Hermetic mocked-backend e2e smoke

  • New website/e2e/smoke-mocked-backend.spec.ts: always runs in CI, intercepts every backend call via page.route (Playwright fulfils before the network), and asserts the static shell renders offline (home hero + /terms). This is the guard that the app boots with no live backend.
  • E2E job also builds/serves against the sentinel; mocked specs intercept that origin.

Validation (local, staging untouched)

Check Result
next build vs unreachable backend ✅ ~9s (was hanging >60s), /sitemap.xml prerendered static
New smoke spec ✅ 2/2 pass
Full e2e suite, CI-style (no E2E_*) ✅ 22 live-only skip, 2 smoke pass
Typecheck / lint / prettier ✅ clean
Vitest ✅ 192 pass

https://claude.ai/code/session_01EJDqbVAWGNdmx9njh4hME8

senamakel added 2 commits July 5, 2026 02:03
…ever depends on a live backend

`next build` prerenders app/sitemap.ts, which reads the directory. It used the
default client (30s timeout x 3 retries = up to ~90s), so a slow or down backend
would hang the build past Next's per-route timeout and fail it — exactly the
staging-502 failure mode seen in CI.

- Add createReadOnlyClient(): an unauthenticated, retry-free, short-timeout
  (8s) client for build-time/crawler reads. The existing try/catch still falls
  back to static routes; this only bounds how long an outage may block.
- Point the CI Build job's NEXT_PUBLIC_API_BASE_URL at an unreachable sentinel
  so the build provably never contacts staging (reads fail fast -> static).

Verified: `next build` against an unreachable backend now completes in ~9s with
/sitemap.xml prerendered statically, instead of hanging.

Claude-Session: https://claude.ai/code/session_01EJDqbVAWGNdmx9njh4hME8
Every existing Playwright spec is gated behind E2E_LIVE / E2E_X402 / API_URL and
skips in CI, so the E2E job's only real work was `next build` — which reached
staging and failed when staging was down. Nothing actually exercised the app
against a mocked backend.

- Add smoke-mocked-backend.spec.ts: always-on, intercepts every backend call
  (Playwright fulfils before the network), and asserts the static shell renders
  offline (home hero + /terms). This is the guard that the app boots with no
  live backend.
- Point the E2E job's NEXT_PUBLIC_API_BASE_URL at an unreachable sentinel so the
  build and served app never contact staging; mocked specs intercept that origin.

Verified: full suite CI-style => 22 live-only specs skip, 2 smoke tests pass,
zero staging contact.

Claude-Session: https://claude.ai/code/session_01EJDqbVAWGNdmx9njh4hME8
@vercel

vercel Bot commented Jul 5, 2026

Copy link
Copy Markdown

@senamakel is attempting to deploy a commit to the Vezures Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 49 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e3e94ca6-be3a-4c19-8fc3-e2d952fe7209

📥 Commits

Reviewing files that changed from the base of the PR and between 453c292 and 4eafbfe.

📒 Files selected for processing (5)
  • .github/workflows/ci.yml
  • .github/workflows/e2e.yml
  • website/app/sitemap.ts
  • website/e2e/smoke-mocked-backend.spec.ts
  • website/src/common/api-client.ts

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4eafbfe5ab

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

return route.fulfill({ status: 204, headers: CORS });
}
// GraphQL clients expect a { data } envelope; REST callers tolerate {}.
const body = request.url().includes("/graphql") ? { data: {} } : {};

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Return an error or valid terms payload from the mock

When the /terms smoke runs, this REST mock makes client.docs.terms() resolve successfully to {}. Terms treats any truthy data as a real TermsDocument and calls parseTermsSections(data.text, ...), which throws because text is undefined, so the route can client-crash while the test still passes with only <body> visible. Return a non-2xx response for generic REST failures, or a valid TermsDocument for /terms, so this actually exercises the offline fallback.

Useful? React with 👍 / 👎.

@senamakel senamakel merged commit e21d154 into tinyhumansai:main Jul 5, 2026
9 of 10 checks passed
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