Repository navigation
fix: stop prerendering two browsers, never resend a failed origin request, fall back on 5xx - #8
Open
OpsBeaconCharles wants to merge 1 commit into
Open
OpsBeaconCharles wants to merge 1 commit into
OpsBeaconCharles wants to merge 1 commit into
Conversation
…uest, fall back on 5xx - Drop yabrowser and sznprohlizec from BOT_AGENTS: they are the UA tokens of Yandex Browser and Seznam's browser, so human visitors got snapshots and used the customer's render quota. - Guard only the Prerender call. The catch used to wrap the non-bot origin fetch too, so a rejected origin request (e.g. a POST) was sent again. - Fall back to the origin when Prerender answers 5xx, not only when the fetch throws. - BOT_AGENTS entries are already lowercase; stop lowercasing each one on every request. Fixes #7. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Fixes #7.
Changes
BOT_AGENTS:yabrowser(Yandex Browser) andsznprohlizec(Seznam's browser). Matching is by substring, so real visitors on those browsers were getting Prerender snapshots and using the site's render quota. The Yandex and Seznam crawlers are still matched, throughyandexbotandseznambot.try. The old.catch(() => fetch(request))also wrapped the non-botfetch(request). A rejected origin request, such as a POST on a connection reset, was therefore sent again, or threw "body already used".ctx.passThroughOnException()still covers anything thrown outside thetry.BOT_AGENTSentries are already lowercase, so the per-requestbot.toLowerCase()is gone. A comment says to keep the entries lowercase.shouldPrerender/prerenderRequest.Deliberately not changed
pinterest,tiktok,naverandecosiaare broad substrings that may also match in-app browsers or apps; for example, Pinterest's in-app browser UA contains "Pinterest". I didn't verify these and left them alone. Narrowing them to the crawler tokens (pinterestbot,tiktokspider, …) needs a check against real UAs first. That's also why the redundant specific entries stay: they're what's left if the broad ones go.Testing
I ran the old and new
worker.jsagainst a stubbedfetchon 12 cases:X-Prerenderrequests and ordinary Chrome all going to the origin.Results: the old Worker fails exactly the 4 bug cases (8/12), and the new one passes 12/12. The repo has no test harness, so the script isn't included.
After merge
The Prerender dashboard ships a verbatim copy of this file (
views/dashboard/public/assets/markdown/onboarding/integrationContents/cloudflare.md), and the public docs show it too. Both get re-copied frommainonce this merges.🤖 Generated with Claude Code