Stop the service-worker check reading Cloudflare's cached 404 - #104
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.jsis present with the build's timestamp, the app serves it (127.0.0.1:4321/sw.js→ 200text/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-scalenehas a window where the build has replaceddist/clientbut 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 200text/javascriptwhile the plain URL is what it is. YAML parses.Not addressed here: the restart window itself. Nothing user-facing depends on
/sw.jsfor those few seconds, but if the 404s in the Cloudflare log are worth closing, the fix is indeploy-scalene— build to a staging directory and swap.🤖 Generated with Claude Code
https://claude.ai/code/session_01Tx3ywgRQLzzrZWNcSdtTpr