Repository navigation
fix(traffic): wait a few minutes before reading a failed bot range list again - #1251
Conversation
…st again A bot's published IP range list that had never loaded was fetched again for every request with that bot's user agent, and a batch verifies its requests one after another, so each waited out the 10 s timeout in turn. After a failed first read the list is now tried again only after RANGES_RETRY_MS (5 minutes), and requests that need a list being read share that one read. A failed refresh still keeps the last list for an hour. Follow-up to ansvisor#1179's review. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@gkhngyk the range-file note from #1179: a failed first read is now remembered for 5 minutes, and concurrent requests share the fetch under way. Checked against a real 10 s timeout: five concurrent requests made one fetch, and the next one returned at once. The generated Worker note ( |
gkhngyk
left a comment
There was a problem hiding this comment.
Looks good. Remembering a failed first read for a few minutes and sharing the read in flight fixes the 100 × 10 s case.
Optional, for later: once a day, when a list is older than its TTL and a refresh is under way, requests wait for that refresh even though a usable list is still in memory. Returning the stale list right away while the refresh runs would remove that wait.
Once a day, when a range list was past its TTL, the requests that needed it waited for the refresh even though a usable list was still in memory. They now use that list at once while the one shared read runs; only a request with no list to use waits for it. Follow-up to gkhngyk's note on #1251. Co-authored-by: Cihan <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
Summary
Follow-up from #1179's review (not blocking there): "Range-file retries: in
ai-bots.js, a range file that fails to load is fetched again for every request with that bot's user agent, one after another, with a 10 s timeout each. Caching the failure for a few minutes and sharing the in-flight fetch avoids that."Before: with no list ever read, a failed fetch cached nothing.
verifyRequestschecks a batch's requests in turn, so a Worker batch of 100 GPTBot requests during an OpenAI outage could wait 100 × 10 s.Now (
server/src/lib/ai-bots.js,rangesFor)RANGES_RETRY_MS(5 minutes). Until then that bot's requests read asno_rangesat once, as they already did after the wait.pendingmap).untilinstead ofat, so the three cases share one check.Related issue
Follow-up to #1179.
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
Unit tests (
ai-bots.test.js). Both new ones fail on the old code:RANGES_RETRY_MS, then is;Against a real timeout: a script calling the branch's
rangesForfor an unroutable address (https://10.255.255.1/ranges.json, so the real fetch waits out its 10 s):Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/) — web not touchedyarn typecheckpasses (run fromweb/) — web not touchedyarn format:checkpasses (run fromweb/) — web not touchedServer:
npm run format,npm run lint,npm test(1841) pass.🤖 Generated with Claude Code