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.
TypeScript apifyautomationcrawlercrawlingheadlessheadless-chromejavascriptnodejsnpmplaywrightpuppeteerscraperscrapingtypescriptweb-crawlerweb-crawlingweb-scraping
chore: fix `sessionRotationCount` when running on apify platform
Martin Adámekc4fb5e26a387
diff --git a/packages/core/src/request.ts b/packages/core/src/request.tsindex 164729ae8..7ef2b97fd 100644--- a/packages/core/src/request.ts+++ b/packages/core/src/request.ts@@ -108,9 +108,6 @@ export class Request<UserData extends Dictionary = Dictionary> {/** The `true` value indicates that the request will not be automatically retried on error. */noRetry: boolean;- /** Indicates the number of times the crawling of the request has rotated the session due to a session or a proxy error. */- sessionRotationCount?: number;-/** Indicates the number of times the crawling of the request has been retried on error. */retryCount: number;@@ -264,6 +261,20 @@ export class Request<UserData extends Dictionary = Dictionary> {}}+ /** Indicates the number of times the crawling of the request has rotated the session due to a session or a proxy error. */+ get sessionRotationCount(): number {+ return this.userData.__crawlee?.sessionRotationCount ?? false;+ }++ /** Indicates the number of times the crawling of the request has rotated the session due to a session or a proxy error. */+ set sessionRotationCount(value: number) {+ if (!this.userData.__crawlee) {+ (this.userData as Dictionary).__crawlee = { sessionRotationCount: value };+ } else {+ this.userData.__crawlee.sessionRotationCount = value;+ }+ }+/** shortcut for getting `request.userData.label` */get label(): string | undefined {return this.userData.label;