Skip to content

Harden build-time API fetches against transient failures#204

Open
gcutrini wants to merge 5 commits into
mainfrom
feature/build-api-error-resilience
Open

Harden build-time API fetches against transient failures#204
gcutrini wants to merge 5 commits into
mainfrom
feature/build-api-error-resilience

Conversation

@gcutrini

Copy link
Copy Markdown
Contributor

ref: https://app.clickup.com/t/86ba4uy6z

Summary

  • Replace the swallowing .catch(e => console.log(...)) pattern in every build-time SSR fetcher with a SSR_handleError helper that throws an Error including HTTP status, URL, and axios cause.
  • Set a 30s default axios timeout so a hung connection cannot stall the Netlify build.
  • Make getAccessToken throw on failure instead of returning undefined, which previously caused every downstream request to fail with a misleading 401.
  • Add a getWithRetry helper (src/utils/build-json/getWithRetry.js) with exponential backoff that retries on 502/503/504 and network errors. Wired into all build-time API fetches.
  • Cap parallel page fetches in SSR_GetRemainingPages at 5 instead of unbounded Promise.all, so high-volume summits no longer fire 25+ concurrent requests per endpoint.

Background

A yoco Netlify build (event-site 2.1.53, summit 69) failed when one of the parallel speaker page fetches returned a transient HTTP 502. The error was swallowed, the next line accessed .length on undefined, and the build crashed with a confusing TypeError instead of a useful "HTTP 502 on speakers endpoint" message. Other client themes succeeded at the same time because they had 0-1 remaining pages versus yoco's 26+.

gcutrini added 5 commits May 27, 2026 07:22
Build-time SSR fetchers were catching errors with console.log and returning
undefined, causing downstream code to crash with confusing TypeError on
.length. Replaces the swallow pattern with a SSR_handleError helper that
throws an Error including HTTP status, URL, and the original axios error
as cause.
Prevents a hung upstream connection from stalling the Netlify build.
Previously a token-fetch failure was logged and the function returned
undefined, causing every downstream SSR_get* call to fail with a misleading
401 instead of the actual auth issue.
…equests

Adds getWithRetry helper with exponential backoff that retries on 502/503/504
or network errors. Wired into all build-time API fetches so a single transient
hiccup no longer fails the entire build.
Pagination remainder fetches were fanned out unbounded via Promise.all. For
high-volume summits this caused 25+ concurrent requests per endpoint, raising
the probability of upstream timeouts. Now processed in chunks of 5.
@netlify

netlify Bot commented May 27, 2026

Copy link
Copy Markdown

Deploy Preview for qa-fnvirtual ready!

Name Link
🔨 Latest commit 4c9d2e5
🔍 Latest deploy log https://app.netlify.com/projects/qa-fnvirtual/deploys/6a16c8b295c6330008be3b42
😎 Deploy Preview https://deploy-preview-204--qa-fnvirtual.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@gcutrini gcutrini requested a review from smarcet May 27, 2026 10:35
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