Skip to content

fix: raise maxDuration to 300s, extend sitemap JS timeout to 240s - #2095

Open
Flotapponnier wants to merge 1 commit into
mainfrom
hotfix/sitemap-sigkill
Open

fix: raise maxDuration to 300s, extend sitemap JS timeout to 240s#2095
Flotapponnier wants to merge 1 commit into
mainfrom
hotfix/sitemap-sigkill

Conversation

@Flotapponnier

Copy link
Copy Markdown
Collaborator

Root cause

Vercel logs confirm Node.js process exited with signal: 9 (SIGKILL) on every /sitemap.xml request since ~Aug 8.

The sequence:

  1. unstable_cache in loadAggregateFromBlob can't store the 4.25 MB blob (Next.js Data Cache hard cap is 2 MB), confirmed by repeated log warnings: items over 2MB can not be cached (4252793 bytes)
  2. So every sitemap request re-fetches from /api/aggregate (no caching possible)
  3. /api/aggregate fetches from the Paris VPS — cold fetches take 18-65 s (FETCH_TIMEOUT_MS = 65_000)
  4. maxDuration = 60 → Vercel sends SIGKILL at 60 s before the fetch can resolve
  5. SIGKILL discards the buffered response → Vercel returns 500

The prior JS timeout at 55 s was designed to fire before SIGKILL and return the static fallback, but the background buildFullSitemap() promise (holding the open 65 s fetch) kept the event loop alive past 60 s, preventing clean exit.

Fix

  • maxDuration 60 → 300: gives the function time to either complete the full build or exit cleanly after the JS timeout fires
  • JS timeout 55 s → 240 s: allows the aggregate fetch (≤65 s) + HL-builder Prometheus sweeps to complete before falling back to the static sitemap

What to do after merging

The workflow file (.github/workflows/prod-deploy.yml) also needs /api/aggregate added to the warm-up step so the ISR cache is hot before the smoke test. That requires workflow scope on the push token — do it as a follow-up or re-auth with gh auth refresh -h github.com -s workflow.

Test plan

  • Smoke test should pass: function now completes within 300 s
  • Cold start: aggregate fetches in 30-65 s, full sitemap builds in 50-95 s, returns 750+ URLs
  • ISR-warm start: aggregate from CDN in <1 s, full sitemap in ~20 s

🤖 Generated with Claude Code

SIGKILL (signal 9) was killing the function at 60s. The aggregate blob
(4.25MB) exceeds Next.js Data Cache's 2MB cap, so unstable_cache never
caches it and every request re-fetches from /api/aggregate (FETCH_TIMEOUT_MS
= 65s > maxDuration = 60s). SIGKILL discards the buffered response -> 500.

- maxDuration 60 -> 300: gives full build time on cold starts
- JS timeout 55s -> 240s: allows aggregate fetch + HL-builder Prometheus
  sweeps to finish before falling back to the static sitemap
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