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
Add throttling to critical memory overload warnings
Ondra Urband6ef87c754ad
diff --git a/src/autoscaling/snapshotter.js b/src/autoscaling/snapshotter.jsindex 86298455d..75866e7c1 100644--- a/src/autoscaling/snapshotter.js+++ b/src/autoscaling/snapshotter.js@@ -20,6 +20,7 @@ const DEFAULT_OPTIONS = {};const RESERVE_MEMORY_RATIO = 0.5;const CLIENT_RATE_LIMIT_ERROR_RETRY_COUNT = 2;+const CRITICAL_OVERLOAD_RATE_LIMIT_MILLIS = 10000;/*** Creates snapshots of system resources at given intervals and marks the resource@@ -124,6 +125,8 @@ class Snapshotter {this.clientInterval = null;this.cpuInterval = null;+ this.lastLoggedCriticalMemoryOverloadAt = 0;+// We need to pre-bind those functions to be able to successfully remove listeners.this._snapshotCpuOnPlatform = this._snapshotCpuOnPlatform.bind(this);this._snapshotMemoryOnPlatform = this._snapshotMemoryOnPlatform.bind(this);@@ -281,6 +284,8 @@ class Snapshotter {* @param {Object} systemInfo*/_memoryOverloadWarning({ memCurrentBytes }) {+ if (Date.now() < this.lastLoggedCriticalMemoryOverloadAt + CRITICAL_OVERLOAD_RATE_LIMIT_MILLIS) return;+const maxDesiredMemoryBytes = this.maxUsedMemoryRatio * this.maxMemoryBytes;const reserveMemory = this.maxMemoryBytes * (1 - this.maxUsedMemoryRatio) * RESERVE_MEMORY_RATIO;const criticalOverloadBytes = maxDesiredMemoryBytes + reserveMemory;