@crawlee/cli 4.0.0-beta.324 → 4.0.0-beta.326

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crawlee/cli",
3
- "version": "4.0.0-beta.324",
3
+ "version": "4.0.0-beta.326",
4
4
  "description": "The scalable web crawling and scraping library for JavaScript/Node.js. Enables development of data extraction and web automation jobs (not only) with headless Chrome and Puppeteer.",
5
5
  "engines": {
6
6
  "node": ">=22.13.0"
@@ -45,7 +45,7 @@
45
45
  "access": "public"
46
46
  },
47
47
  "dependencies": {
48
- "@crawlee/templates": "4.0.0-beta.324",
48
+ "@crawlee/templates": "4.0.0-beta.326",
49
49
  "@inquirer/prompts": "^8.8.1",
50
50
  "ansi-colors": "^4.1.3",
51
51
  "semver": "^7.8.5",
@@ -59,5 +59,5 @@
59
59
  }
60
60
  }
61
61
  },
62
- "gitHead": "0ab0dda221e47075adcd6a8bc479559248b79637"
62
+ "gitHead": "0e8e224089155cf1170dadafc99f49308d9a2875"
63
63
  }
@@ -154,7 +154,7 @@ try {
154
154
  }
155
155
  ```
156
156
 
157
- One behavioral change: options validated against class interfaces (`httpClient`, `configuration`, `eventManager`) now require actual instances (`instanceof BaseHttpClient`, …) rather than duck-typed plain objects — extend the class (or `Object.create(BaseHttpClient.prototype)` in tests) instead of passing an object literal.
157
+ One behavioral change: options validated against class interfaces (`httpClient`, `configuration`) now require actual instances (`instanceof BaseHttpClient`, …) rather than duck-typed plain objects — extend the class (or `Object.create(BaseHttpClient.prototype)` in tests) instead of passing an object literal.
158
158
 
159
159
  ### Zod 4 required
160
160
 
@@ -374,10 +374,10 @@ const eventManager = serviceLocator.getEventManager();
374
374
 
375
375
  #### Using per-crawler services (recommended)
376
376
 
377
- The new `ServiceLocator` supports per-crawler service isolation, allowing you to use different storage backends or event managers for different crawlers by passing them via options:
377
+ The new `ServiceLocator` supports per-crawler service isolation, allowing you to use a different configuration, storage backend or logger for different crawlers by passing them via options:
378
378
 
379
379
  ```typescript
380
- import { BasicCrawler, Configuration, LocalEventManager, MemoryStorageBackend } from 'crawlee';
380
+ import { BasicCrawler, Configuration, MemoryStorageBackend } from 'crawlee';
381
381
 
382
382
  const crawler = new BasicCrawler({
383
383
  requestHandler: async ({ request, log }) => {
@@ -385,7 +385,6 @@ const crawler = new BasicCrawler({
385
385
  },
386
386
  configuration: new Configuration({ headless: false }),
387
387
  storageBackend: new MemoryStorageBackend(),
388
- eventManager: LocalEventManager.fromConfiguration(),
389
388
  });
390
389
 
391
390
  await crawler.run(['https://example.com']);
@@ -456,6 +455,15 @@ Renamed properties — `Dataset.config`, `KeyValueStore.config` and `BrowserLaun
456
455
 
457
456
  The `configuration` crawler option is unchanged, as are `serviceLocator.getConfiguration()` and `serviceLocator.setConfiguration()`.
458
457
 
458
+ ### The event manager no longer follows the crawler run
459
+
460
+ There is a single event manager per process, shared by all crawlers, and `crawler.run()` no longer initializes and closes it. It starts itself with the first listener and emits a final `persistState` event before the process exits, so a `RequestList`, a `SitemapRequestLoader` or a `KeyValueStore.getAutoSavedValue()` used outside of a crawler now persists its state periodically too. A crawler emits `persistState` at the end of every run.
461
+
462
+ - Calling `init()` yourself takes over the lifecycle, and it is then on you to call `close()`. A custom event manager that needs to await something to start (e.g. a connection) has to be initialized this way.
463
+ - To use a custom event manager, call `serviceLocator.setEventManager()` before anything else resolves one.
464
+ - `persistStateIntervalMillis` and `systemInfoIntervalMillis` are read from the configuration of whoever resolves the event manager first, so set them on the global configuration rather than on the one passed to a crawler.
465
+ - `LocalEventManager` emits `systemInfo` events only while something listens to them.
466
+
459
467
  ### Navigation and the request handler are timed separately
460
468
 
461
469
  In v3, navigation ran inside the request handler's time window, and the two options were summed (plus an undocumented 10 second buffer) to form the actual limit. Setting `requestHandlerTimeoutSecs: 60` on a `PlaywrightCrawler` therefore produced errors complaining about 130 seconds.