@crawlee/core 4.0.0-beta.255 → 4.0.0-beta.256

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/core",
3
- "version": "4.0.0-beta.255",
3
+ "version": "4.0.0-beta.256",
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"
@@ -53,10 +53,10 @@
53
53
  "@apify/log": "^3.0.1",
54
54
  "@apify/timeout": "^1.0.1",
55
55
  "@apify/utilities": "^3.1.0",
56
- "@crawlee/fs-storage": "4.0.0-beta.255",
57
- "@crawlee/http-client": "4.0.0-beta.255",
58
- "@crawlee/types": "4.0.0-beta.255",
59
- "@crawlee/utils": "4.0.0-beta.255",
56
+ "@crawlee/fs-storage": "4.0.0-beta.256",
57
+ "@crawlee/http-client": "4.0.0-beta.256",
58
+ "@crawlee/types": "4.0.0-beta.256",
59
+ "@crawlee/utils": "4.0.0-beta.256",
60
60
  "@sapphire/async-queue": "^1.5.5",
61
61
  "@standard-schema/spec": "^1.1.0",
62
62
  "@vladfrangu/async_event_emitter": "^2.4.7",
@@ -76,5 +76,5 @@
76
76
  }
77
77
  }
78
78
  },
79
- "gitHead": "e1b2f6c415f90b3eca1686a39a8af5272b54046e"
79
+ "gitHead": "06cbfcc77b373a93f1a6a048e8115433db98c862"
80
80
  }
@@ -1,4 +1,5 @@
1
1
  import type { ProcessedRequest } from '@crawlee/types';
2
+ import type { CrawleeLogger } from '../log.js';
2
3
  import type { Source } from '../request.js';
3
4
  import type { AddRequestsBatchedResult } from './request-queue.js';
4
5
  export interface DrainRequestBatchesOptions<TItem extends Source> {
@@ -11,6 +12,7 @@ export interface DrainRequestBatchesOptions<TItem extends Source> {
11
12
  waitBetweenBatchesMillis: number;
12
13
  waitForAllRequestsToBeAdded: boolean;
13
14
  maxNewRequests?: number;
15
+ log: CrawleeLogger;
14
16
  /**
15
17
  * Adds a single chunk and reports what it processed.
16
18
  *
@@ -12,7 +12,7 @@ import { activeStorageTransaction, withDirectStorageAccess } from './transaction
12
12
  * so that is read from the ambient transaction rather than asked of the caller.
13
13
  */
14
14
  export async function drainRequestBatches(options) {
15
- const { items, batchSize, waitBetweenBatchesMillis, waitForAllRequestsToBeAdded, maxNewRequests, processChunk, trackBackgroundBatches, } = options;
15
+ const { items, batchSize, waitBetweenBatchesMillis, waitForAllRequestsToBeAdded, maxNewRequests, log, processChunk, trackBackgroundBatches, } = options;
16
16
  const deferred = activeStorageTransaction()?.policy.requestQueue === 'deferred';
17
17
  let remainingBudget = maxNewRequests ?? Infinity;
18
18
  const requestsOverLimit = [];
@@ -64,8 +64,13 @@ export async function drainRequestBatches(options) {
64
64
  // See `StorageTransactionView.enqueuedUrls`.
65
65
  const remainder = awaitsRemainder ? processRemainingChunks() : withDirectStorageAccess(processRemainingChunks);
66
66
  // The caller is not obliged to await `remainder`, so give it a handler of its own - an unhandled
67
- // rejection here would otherwise take the process down.
68
- trackBackgroundBatches?.(remainder.catch(() => { }));
67
+ // rejection here would otherwise take the process down. Awaited failures reach the caller, so only
68
+ // background ones get logged.
69
+ trackBackgroundBatches?.(remainder.catch((error) => {
70
+ if (!awaitsRemainder) {
71
+ log.exception(error, 'A batch of requests could not be added to the queue in the background');
72
+ }
73
+ }));
69
74
  if (awaitsRemainder) {
70
75
  addedRequests.push(...(await remainder));
71
76
  }
@@ -498,6 +498,7 @@ export class RequestQueue {
498
498
  waitBetweenBatchesMillis,
499
499
  waitForAllRequestsToBeAdded,
500
500
  maxNewRequests,
501
+ log: this.log,
501
502
  /**
502
503
  * Requests the backend reports as unprocessed are warned about and skipped rather than retried:
503
504
  * `unprocessedRequests` is what remains after the backend's own transient-error handling - a