@crawlee/basic 4.0.0-beta.75 → 4.0.0-beta.77

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.
@@ -451,6 +451,11 @@ export class BasicCrawler {
451
451
  }
452
452
  throw this.unwrapError(error);
453
453
  }
454
+ finally {
455
+ // Run request-scoped deferred cleanups only after the whole request lifecycle - including the user's error handler - has finished.
456
+ const deferredCleanup = crawlingContext[deferredCleanupKey] ?? [];
457
+ await Promise.all(deferredCleanup.map((fn) => fn().catch((cleanupError) => this.log.debug('Error in deferred cleanup', { error: cleanupError }))));
458
+ }
454
459
  },
455
460
  isTaskReadyFunction: async () => {
456
461
  if (isMaxPagesExceeded()) {
@@ -513,12 +518,7 @@ export class BasicCrawler {
513
518
  buildBasicContextPipeline() {
514
519
  return ContextPipeline.create()
515
520
  .compose({ action: this.checkRobotsTxt.bind(this) })
516
- .compose({
517
- action: () => this.createBaseContext(),
518
- cleanup: async (context) => {
519
- await Promise.all(context[deferredCleanupKey].map((fn) => fn()));
520
- },
521
- })
521
+ .compose({ action: () => this.createBaseContext() })
522
522
  .compose({ action: this.resolveSession.bind(this) })
523
523
  .compose({ action: this.createContextHelpers.bind(this) });
524
524
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crawlee/basic",
3
- "version": "4.0.0-beta.75",
3
+ "version": "4.0.0-beta.77",
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.0.0"
@@ -42,10 +42,10 @@
42
42
  "@apify/datastructures": "^2.0.0",
43
43
  "@apify/timeout": "^0.3.2",
44
44
  "@apify/utilities": "^2.15.5",
45
- "@crawlee/core": "4.0.0-beta.75",
46
- "@crawlee/http-client": "4.0.0-beta.75",
47
- "@crawlee/types": "4.0.0-beta.75",
48
- "@crawlee/utils": "4.0.0-beta.75",
45
+ "@crawlee/core": "4.0.0-beta.77",
46
+ "@crawlee/http-client": "4.0.0-beta.77",
47
+ "@crawlee/types": "4.0.0-beta.77",
48
+ "@crawlee/utils": "4.0.0-beta.77",
49
49
  "csv-stringify": "^6.5.2",
50
50
  "fs-extra": "^11.3.0",
51
51
  "ow": "^2.0.0",
@@ -54,7 +54,7 @@
54
54
  "type-fest": "^4.41.0"
55
55
  },
56
56
  "optionalDependencies": {
57
- "@crawlee/impit-client": "^4.0.0-beta.75"
57
+ "@crawlee/impit-client": "^4.0.0-beta.77"
58
58
  },
59
59
  "lerna": {
60
60
  "command": {
@@ -63,5 +63,5 @@
63
63
  }
64
64
  }
65
65
  },
66
- "gitHead": "298b8eeaec01f1d0ab8e6d58461d7268afdafbba"
66
+ "gitHead": "671ef0dab0f67275d0db5c289b940ea100ad3ef9"
67
67
  }