AppView in a box as a Vite plugin thing hatk.dev
4
fork

Configure Feed

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

fix: use exit(1) for post-backfill restart, only restart if work done

- runBackfill returns record count instead of void
- Only restart after backfill if records were actually processed
- Use exit(1) so Railway restarts the container

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

+11 -8
+3 -2
packages/hatk/src/backfill.ts
··· 366 366 * }) 367 367 * ``` 368 368 */ 369 - export async function runBackfill(opts: BackfillOpts): Promise<void> { 369 + export async function runBackfill(opts: BackfillOpts): Promise<number> { 370 370 const { pdsUrl, collections, config } = opts 371 371 plcUrl = opts.plcUrl 372 372 const signalCollections = config.signalCollections || [...collections] ··· 430 430 parallelism: config.parallelism, 431 431 status: 'success', 432 432 }) 433 - return 433 + return 0 434 434 } 435 435 436 436 // 3. Backfill with worker pool ··· 495 495 retry_rounds: retryRound, 496 496 status: failedCount > 0 ? 'partial' : 'success', 497 497 }) 498 + return totalRecords 498 499 }
+8 -6
packages/hatk/src/main.ts
··· 185 185 collections: collectionSet, 186 186 config: config.backfill, 187 187 }) 188 - .then(() => { 188 + .then((recordCount) => { 189 189 log('[main] Backfill complete, rebuilding FTS indexes...') 190 - return rebuildAllIndexes(collections) 190 + return rebuildAllIndexes(collections).then(() => recordCount) 191 191 }) 192 - .then(() => { 192 + .then((recordCount) => { 193 193 log('[main] FTS indexes ready') 194 - logMemory('after-backfill') 195 - log('[main] Restarting to reclaim memory...') 196 - process.exit(0) 194 + if (recordCount > 0) { 195 + logMemory('after-backfill') 196 + log('[main] Restarting to reclaim memory...') 197 + process.exit(1) 198 + } 197 199 }) 198 200 .catch((err) => { 199 201 console.error('[main] Backfill error:', err.message)