fix: decouple build + e2e from a live backend (staging)#225
Conversation
…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
|
@senamakel is attempting to deploy a commit to the Vezures Team on Vercel. A member of the Team first needs to authorize it. |
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 49 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
Comment |
There was a problem hiding this comment.
💡 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: {} } : {}; |
There was a problem hiding this comment.
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 👍 / 👎.
Problem
next buildprerendersapp/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 runnext buildfirst, 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_URLand 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
createReadOnlyClient()inwebsite/src/common/api-client.ts: unauthenticated, no retries, 8s timeout, for build-time/crawler reads. The existingtry/catchinsitemap.tsstill degrades to static routes on failure — this only caps how long an outage may block the build.NEXT_PUBLIC_API_BASE_URLpointed 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
website/e2e/smoke-mocked-backend.spec.ts: always runs in CI, intercepts every backend call viapage.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.Validation (local, staging untouched)
next buildvs unreachable backend/sitemap.xmlprerendered staticE2E_*)https://claude.ai/code/session_01EJDqbVAWGNdmx9njh4hME8