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
refactor: error analysis message (#1534)
Szymon Marczakc0b6ee3b4e3a
diff --git a/packages/basic-crawler/src/internals/basic-crawler.ts b/packages/basic-crawler/src/internals/basic-crawler.tsindex 430daf2cb..d5ea529e7 100644--- a/packages/basic-crawler/src/internals/basic-crawler.ts+++ b/packages/basic-crawler/src/internals/basic-crawler.ts@@ -595,10 +595,12 @@ export class BasicCrawler<Context extends CrawlingContext = BasicCrawlingContextthis.log.info('Crawl finished. Final request statistics:', stats);if (this.stats.errorTracker.total !== 0) {+ const prettify = ([count, info]: [number, string[]]) => `${count}x: ${info.at(-1)!.trim()} (${info[0]})`;+this.log.info(`Error analysis:`, {totalErrors: this.stats.errorTracker.total,uniqueErrors: this.stats.errorTracker.getUniqueErrorCount(),- mostCommonErrors: Object.fromEntries(this.stats.errorTracker.getMostPopularErrors(3)),+ mostCommonErrors: this.stats.errorTracker.getMostPopularErrors(3).map(prettify),});}diff --git a/packages/utils/src/internals/error_tracker.ts b/packages/utils/src/internals/error_tracker.tsindex a06862a87..f32814c9a 100644--- a/packages/utils/src/internals/error_tracker.ts+++ b/packages/utils/src/internals/error_tracker.ts@@ -353,7 +353,7 @@ export class ErrorTracker {goDeeper(this.result, []);- return result.sort((a, b) => a[0] - b[0]).slice(0, count);+ return result.sort((a, b) => b[0] - a[0]).slice(0, count);}reset() {