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.

fix: mark session as bad on failed requests (#1647)

Jindřich Bär445ae4321816
diff --git a/packages/basic-crawler/src/internals/basic-crawler.ts b/packages/basic-crawler/src/internals/basic-crawler.ts
index 5c9e49033..5606ae4a7 100644
--- a/packages/basic-crawler/src/internals/basic-crawler.ts
+++ b/packages/basic-crawler/src/internals/basic-crawler.ts
@@ -951,6 +951,8 @@ export class BasicCrawler<Context extends CrawlingContext = BasicCrawlingContext
}
throw secondaryError;
}
+ // decrease the session score if the request fails (but the error handler did not throw)
+ session?.markBad();
} finally {
await this._cleanupContext(crawlingContext);