···9797 let sitesSynced = 0
9898 let sitesFailed = 0
9999100100- for (const did of dids) {
100100+ const concurrency = config.backfillConcurrency
101101+102102+ const processDid = async (did: string) => {
101103 try {
102104 const records = await listSiteRecordsForDid(did)
103105 for (const row of records) {
···112114 }
113115 }
114116 didsProcessed++
115115- logger.info(`[Backfill:sites] Progress ${didsProcessed + didsFailed}/${dids.length} DIDs`)
116117 } catch (err) {
117118 logger.error(`[Backfill:sites] Failed to list records for DID ${did}`, err)
118119 didsFailed++
119120 }
121121+ logger.info(`[Backfill:sites] Progress ${didsProcessed + didsFailed}/${dids.length} DIDs (${sitesSynced} sites synced, ${sitesFailed} sites failed)`)
120122 }
123123+124124+ const inFlight = new Set<Promise<void>>()
125125+ for (const did of dids) {
126126+ const task = processDid(did).then(() => { inFlight.delete(task) })
127127+ inFlight.add(task)
128128+ if (inFlight.size >= concurrency) {
129129+ await Promise.race(inFlight)
130130+ }
131131+ }
132132+ await Promise.all(inFlight)
121133122134 logger.info(
123135 `Phase 2/3 complete: ${didsProcessed} DIDs processed, ${didsFailed} DIDs failed, ${sitesSynced} sites synced, ${sitesFailed} sites failed`,
+2-2
apps/firehose-service/src/lib/cache-writer.ts
···830830 })
831831 }
832832833833- // Notify hosting-service to invalidate its local caches
834834- // (skip for revalidate/backfill since hosting-service already has the files locally)
833833+ // Notify hosting-service to invalidate its local caches (including negative 404 cache)
834834+ // (skip for backfill since it runs before the hosting-service serves traffic)
835835 if (!options?.skipInvalidation) {
836836 await publishCacheInvalidation(did, rkey, 'update')
837837 }