GET /xrpc/app.bsky.actor.searchActorsTypeahead typeahead.waow.tech
16
fork

Configure Feed

Select the types of activity you want to include in your feed.

add kill switch and global throttle for backfill

KV key "backfill" = "off" disables without redeploy. global rate
limit (10/min) caps total backfill writes regardless of user count.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

+16 -1
+16 -1
src/index.ts
··· 98 98 } 99 99 } 100 100 101 + async function throttledBackfill(term: string, limit: number, env: Env): Promise<void> { 102 + // kill switch — set KV key "backfill" to "off" to disable without redeploying 103 + const flag = await env.KV.get("backfill"); 104 + if (flag === "off") return; 105 + 106 + // global budget — cap total backfill triggers across all users 107 + const { success } = await env.RATE_LIMITER_STRICT.limit({ key: "backfill" }); 108 + if (!success) { 109 + console.log(JSON.stringify({ event: "backfill_throttled", term })); 110 + return; 111 + } 112 + 113 + return backfillFromBsky(term, limit, env); 114 + } 115 + 101 116 // --- end backfill --- 102 117 103 118 async function handleSearch( ··· 148 163 // --- backfill: remove this block once at parity with Bluesky --- 149 164 const hasGaps = actors.length < limit || actors.some((a) => !a.avatar); 150 165 if (hasGaps) { 151 - ctx.waitUntil(backfillFromBsky(term, limit, env)); 166 + ctx.waitUntil(throttledBackfill(term, limit, env)); 152 167 } 153 168 // --- end backfill --- 154 169