See the best posts from any Bluesky account
0
fork

Configure Feed

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

Rename didRefreshTimer and harden webhook URL lookup

Rename JetstreamConsumer.didRefreshTimer to trackedDidsRefreshTimer for
clarity, and derive the threshold webhook env var from THRESHOLDS index
so the two stay in sync.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

+10 -8
+4 -2
app/jobs/threshold_scan_job.ts
··· 14 14 * Thresholds scanned by this job. Ordered ascending so that 15 15 * findPostsAtOrAboveThreshold can be called with the smallest value. 16 16 */ 17 - const THRESHOLDS = [10, 100] as const 17 + const THRESHOLDS = [1000, 10000] as const 18 18 19 19 const WINDOW_DAYS = 7 20 20 ··· 83 83 const raw = this.__testOverrides.webhookUrls[threshold] 84 84 return raw ?? null 85 85 } 86 - const envVar = threshold === 1000 ? 'FIREHOSE_WEBHOOK_URL_1K' : 'FIREHOSE_WEBHOOK_URL_10K' 86 + const index = THRESHOLDS.indexOf(threshold as (typeof THRESHOLDS)[number]) 87 + if (index === -1) return null 88 + const envVar = index === 0 ? 'FIREHOSE_WEBHOOK_URL_1K' : 'FIREHOSE_WEBHOOK_URL_10K' 87 89 const value = process.env[envVar] 88 90 return value && value.length > 0 ? value : null 89 91 }
+6 -6
app/services/jetstream_consumer.ts
··· 137 137 private countsBuffer: LikeCountsDailyDeltaRow[] = [] 138 138 private shutdownRequested = false 139 139 private ws: WebSocketLike | null = null 140 - private didRefreshTimer: ReturnType<typeof setInterval> | null = null 140 + private trackedDidsRefreshTimer: ReturnType<typeof setInterval> | null = null 141 141 private bufferFlushTimer: ReturnType<typeof setInterval> | null = null 142 142 143 143 /** ··· 193 193 194 194 // 3. Set up 1s tracked-DID refresh 195 195 // unref() so leaked timers don't prevent process exit in tests 196 - this.didRefreshTimer = setInterval(() => { 196 + this.trackedDidsRefreshTimer = setInterval(() => { 197 197 void this.refreshTrackedDids() 198 198 }, 1000) 199 - this.didRefreshTimer.unref() 199 + this.trackedDidsRefreshTimer.unref() 200 200 201 201 // 4. Set up 500ms / 1000-row flush interval 202 202 this.bufferFlushTimer = setInterval(() => { ··· 215 215 async shutdown(): Promise<void> { 216 216 this.shutdownRequested = true 217 217 218 - if (this.didRefreshTimer !== null) { 219 - clearInterval(this.didRefreshTimer) 220 - this.didRefreshTimer = null 218 + if (this.trackedDidsRefreshTimer !== null) { 219 + clearInterval(this.trackedDidsRefreshTimer) 220 + this.trackedDidsRefreshTimer = null 221 221 } 222 222 if (this.bufferFlushTimer !== null) { 223 223 clearInterval(this.bufferFlushTimer)