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
Fix teardown in Snapshotter
Ondra Urban04aad84827f8
diff --git a/src/autoscaling/snapshotter.js b/src/autoscaling/snapshotter.jsindex b6f508ec6..86298455d 100644--- a/src/autoscaling/snapshotter.js+++ b/src/autoscaling/snapshotter.js@@ -123,6 +123,10 @@ class Snapshotter {this.memoryInterval = null;this.clientInterval = null;this.cpuInterval = null;++ // 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);}/**@@ -136,8 +140,8 @@ class Snapshotter {this.eventLoopInterval = betterSetInterval(this._snapshotEventLoop.bind(this), this.eventLoopSnapshotIntervalMillis);this.clientInterval = betterSetInterval(this._snapshotClient.bind(this), this.clientSnapshotIntervalMillis);if (isAtHome()) {- events.on(ACTOR_EVENT_NAMES.SYSTEM_INFO, this._snapshotCpuOnPlatform.bind(this));- events.on(ACTOR_EVENT_NAMES.SYSTEM_INFO, this._snapshotMemoryOnPlatform.bind(this));+ events.on(ACTOR_EVENT_NAMES.SYSTEM_INFO, this._snapshotCpuOnPlatform);+ events.on(ACTOR_EVENT_NAMES.SYSTEM_INFO, this._snapshotMemoryOnPlatform);} else {this.cpuInterval = betterSetInterval(this._snapshotCpuOnLocal.bind(this), this.cpuSnapshotIntervalMillis);this.memoryInterval = betterSetInterval(this._snapshotMemoryOnLocal.bind(this), this.memorySnapshotIntervalMillis);