Skip to content

Stop the service-worker check reading Cloudflare's cached 404 - #104

Merged
ssavutu merged 1 commit into
mainfrom
fix/sw-verify-cloudflare-race
Sep 1, 2026
Merged

Stop the service-worker check reading Cloudflare's cached 404#104
ssavutu merged 1 commit into
mainfrom
fix/sw-verify-cloudflare-race

Conversation

@ssavutu

@ssavutu ssavutu commented Sep 1, 2026

Copy link
Copy Markdown
Member

The deploy for #103 failed on "Verify service worker is served" — six retries, all curl: (22) The requested URL returned error: 404. The deploy itself was fine. On the web edge, /var/www/Scalene/dist/client/sw.js is present with the build's timestamp, the app serves it (127.0.0.1:4321/sw.js → 200 text/javascript), and so does nginx. The public URL returned 200 again a couple of minutes later, unchanged.

The 404 was Cloudflare's. It caches 404 responses for about three minutes, and deploy-scalene has a window where the build has replaced dist/client but the app has not restarted — a request landing there falls through to the [sectionSlug] catch-all and comes back as an HTML 404. Cloudflare cached that, and this step then read the cached copy for its entire 30-second retry window.

Give the check a unique query string per run. That is a distinct Cloudflare cache key, so it always reaches the origin, and the check goes back to asserting what was actually deployed.

Verified https://www.thetriangle.org/sw.js?deploy=… returns 200 text/javascript while the plain URL is what it is. YAML parses.

Not addressed here: the restart window itself. Nothing user-facing depends on /sw.js for those few seconds, but if the 404s in the Cloudflare log are worth closing, the fix is in deploy-scalene — build to a staging directory and swap.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Tx3ywgRQLzzrZWNcSdtTpr

The deploy for #103 failed on the service-worker check with six 404s in
a row, while the worker was on disk with the build's timestamp and both
the app and nginx served it 200. Cloudflare caches 404s for about three
minutes, and deploy-scalene has a window where the build has replaced
dist/client but the app has not restarted -- a request landing there
falls through to the [sectionSlug] catch-all as an HTML 404. Cloudflare
cached that, and the check read the cached copy for its whole retry
window.

Give the URL a unique query string per run: a distinct cache key always
reaches the origin, so the check asserts what was deployed rather than
what Cloudflare happens to be holding.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tx3ywgRQLzzrZWNcSdtTpr
@ssavutu
ssavutu merged commit 5c969ae into main Sep 1, 2026
1 check passed
@ssavutu
ssavutu deleted the fix/sw-verify-cloudflare-race branch September 1, 2026 22:59
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