Skip to content

Crawlee—A web scraping and browser automation library for Node.js to build reliable crawlers. In JavaScript and TypeScript. Extract data for AI, LLMs, RAG, or GPTs. Download HTML, PDF, JPG, PNG, and other files from websites. Works with Puppeteer, Playwright, Cheerio, JSDOM, and raw HTTP. Both headful and headless mode. With proxy rotation.

perf: don't await `crawler.setStatusMessage` (#3207)

Lukáš Křivka1a67ffbf22e0
diff --git a/packages/basic-crawler/src/internals/basic-crawler.ts b/packages/basic-crawler/src/internals/basic-crawler.ts
index 811629d68..62b2fe5bb 100644
--- a/packages/basic-crawler/src/internals/basic-crawler.ts
+++ b/packages/basic-crawler/src/internals/basic-crawler.ts
@@ -989,7 +989,8 @@ export class BasicCrawler<Context extends CrawlingContext = BasicCrawlingContext
await this._init();
await this.stats.startCapturing();
const periodicLogger = this.getPeriodicLogger();
- await this.setStatusMessage('Starting the crawler.', { level: 'INFO' });
+ // Don't await, we don't want to block the execution
+ void this.setStatusMessage('Starting the crawler.', { level: 'INFO' });
const sigintHandler = async () => {
this.log.warning(
@@ -1051,12 +1052,14 @@ export class BasicCrawler<Context extends CrawlingContext = BasicCrawlingContext
}
periodicLogger.stop();
- await this.setStatusMessage(
+ // Don't await, we don't want to block the execution
+ void this.setStatusMessage(
`Finished! Total ${this.stats.state.requestsFinished + this.stats.state.requestsFailed} requests: ${
this.stats.state.requestsFinished
} succeeded, ${this.stats.state.requestsFailed} failed.`,
{ isStatusMessageTerminal: true, level: 'INFO' },
);
+
this.running = false;
this.hasFinishedBefore = true;
}