Skip to content

Commit f2360ef

Browse files
committed
fix: handle SIGINT/SIGTERM with keep-alive timer
1 parent d973be7 commit f2360ef

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

packages/scraper/scraper.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ export async function scrape(options: ScrapeOptions) {
142142
// Keep-alive: prevent Bun from exiting when event loop has no native I/O pending
143143
// (Bun may drain the event loop while async generators/promises are still active)
144144
const keepAlive = setInterval(() => {}, 60_000);
145+
const cleanup = () => { clearInterval(keepAlive); process.exit(0); };
146+
process.on("SIGINT", cleanup);
147+
process.on("SIGTERM", cleanup);
145148

146149
header("docx-corpus", version);
147150

0 commit comments

Comments
 (0)