diff --git a/packages/scraper/src/scrapers/fs-com.ts b/packages/scraper/src/scrapers/fs-com.ts index d6fbf43..76c43ea 100644 --- a/packages/scraper/src/scrapers/fs-com.ts +++ b/packages/scraper/src/scrapers/fs-com.ts @@ -810,6 +810,23 @@ export async function scrapeFs(): Promise { } if (require.main === module) { + // Crawlee's FileSystemStorage emits spurious unhandledRejection errors after + // crawler.run() resolves: the internal task loop schedules one final + // _isTaskReadyFunction call which tries to read a request .json file that + // Crawlee already cleaned up during normal processing. This ENOENT is benign + // (crawling is done), but the default unhandledRejection handler would call + // process.exit(1) and abort Phase 2. We swallow it here. + process.on("unhandledRejection", (reason) => { + const msg = reason instanceof Error ? reason.message : String(reason); + if (msg.includes("ENOENT") && msg.includes("request_queues")) { + // Benign Crawlee post-run cleanup race — ignore + return; + } + // All other unhandled rejections are real errors + console.error("Unhandled rejection:", reason); + process.exit(1); + }); + scrapeFs() .then(() => pool.end()) .catch((err) => {