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.

docs(basic-crawler): document .teardown and link with .stop (#3192)

Lukáš Křivkadf79570c70dd
diff --git a/packages/basic-crawler/src/internals/basic-crawler.ts b/packages/basic-crawler/src/internals/basic-crawler.ts
index 9bfa903e4..811629d68 100644
--- a/packages/basic-crawler/src/internals/basic-crawler.ts
+++ b/packages/basic-crawler/src/internals/basic-crawler.ts
@@ -1068,6 +1068,8 @@ export class BasicCrawler<Context extends CrawlingContext = BasicCrawlingContext
* Gracefully stops the current run of the crawler.
*
* All the tasks active at the time of calling this method will be allowed to finish.
+ *
+ * To stop the crawler immediately, use {@apilink BasicCrawler.teardown|`crawler.teardown()`} instead.
*/
stop(message = 'The crawler has been gracefully stopped.'): void {
// Gracefully starve the this.autoscaledPool, so it doesn't start new tasks. Resolves once the pool is cleared.
@@ -1904,8 +1906,11 @@ export class BasicCrawler<Context extends CrawlingContext = BasicCrawlingContext
}
/**
- * Function for cleaning up after all request are processed.
- * @ignore
+ * Stops the crawler immediately.
+ *
+ * This method doesn't wait for currently active requests to finish.
+ *
+ * To stop the crawler gracefully (waiting for all running requests to finish), use {@apilink BasicCrawler.stop|`crawler.stop()`} instead.
*/
async teardown(): Promise<void> {
this.events.emit(EventType.PERSIST_STATE, { isMigrating: false });