Never fail a render or a build on a transient API error: 429/5xx render the calm not-built state; deploy hook uses pipefail so a failed web build fails the deploy
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2 changed files +4 −3
modified
apps/web/src/lib/api.ts
+3 −2
@@ -43,9 +43,10 @@ export class ApiError extends Error { | ||
| 43 | 43 | this.problem = problem; |
| 44 | 44 | this.path = path; |
| 45 | 45 | } |
| 46 | − /** The snapshot does not exist yet (fresh deployment, pipeline still running) — or the API is down. */ | |
| 46 | + /** The data service is unavailable right now: no snapshot yet (503), unreachable (0), rate-limited (429) or failing (5xx). | |
| 47 | + * Pages render the calm "data is being prepared" state for all of these instead of crashing (and never fail a build). */ | |
| 47 | 48 | get notBuilt(): boolean { |
| 48 | − return this.status === 503 || this.status === 0; | |
| 49 | + return this.status === 503 || this.status === 0 || this.status === 429 || this.status >= 500; | |
| 49 | 50 | } |
| 50 | 51 | get notFound(): boolean { |
| 51 | 52 | return this.status === 404; |
modified
deploy/countryatlas.mld.json
+1 −1
@@ -91,7 +91,7 @@ | ||
| 91 | 91 | "post_sync": [ |
| 92 | 92 | "export PATH=\"$HOME/.local/bin:/opt/homebrew/bin:$PATH\"; (test -x .venv/bin/python || uv venv --python 3.12 .venv) && uv pip install -q --python .venv/bin/python -e . && echo ' python deps ok'", |
| 93 | 93 | "export PATH=\"/opt/homebrew/bin:$PATH\"; pnpm install --frozen-lockfile --silent && echo ' web deps ok'", |
| 94 | − "export PATH=\"/opt/homebrew/bin:$PATH\"; cd apps/web && API_URL=http://127.0.0.1:8291 NEXT_PUBLIC_SITE_URL=https://www.countryatlas.co CA_ADMIN_TOKEN=c9ae6c67cdeb415c9df7db09d255c86d3537fb7670cf3c5a NEXT_TELEMETRY_DISABLED=1 pnpm build 2>&1 | tail -3 && echo ' web build ok'", | |
| 94 | + "set -o pipefail; export PATH=\"/opt/homebrew/bin:$PATH\"; cd apps/web && API_URL=http://127.0.0.1:8291 NEXT_PUBLIC_SITE_URL=https://www.countryatlas.co CA_ADMIN_TOKEN=c9ae6c67cdeb415c9df7db09d255c86d3537fb7670cf3c5a NEXT_TELEMETRY_DISABLED=1 pnpm build 2>&1 | tail -3 && echo ' web build ok'", | |
| 95 | 95 | "mkdir -p $HOME/countryatlas-data/{raw,staging,build,snapshots,exports,logs} && echo ' data dirs ok'" |
| 96 | 96 | ], |
| 97 | 97 | "post_start": [] |
| 98 | 98 | |