@crawlee/core 4.0.0-beta.276 → 4.0.0-beta.278
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.
|
|
3
|
+
"version": "4.0.0-beta.278",
|
|
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.
|
|
57
|
-
"@crawlee/http-client": "4.0.0-beta.
|
|
58
|
-
"@crawlee/types": "4.0.0-beta.
|
|
59
|
-
"@crawlee/utils": "4.0.0-beta.
|
|
56
|
+
"@crawlee/fs-storage": "4.0.0-beta.278",
|
|
57
|
+
"@crawlee/http-client": "4.0.0-beta.278",
|
|
58
|
+
"@crawlee/types": "4.0.0-beta.278",
|
|
59
|
+
"@crawlee/utils": "4.0.0-beta.278",
|
|
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": "
|
|
79
|
+
"gitHead": "745f27ebf5c8307d949416c9c884ab941eef1559"
|
|
80
80
|
}
|
|
@@ -70,7 +70,7 @@ export declare class RequestManagerTandem implements IRequestManager {
|
|
|
70
70
|
* reserved. The manager is opened lazily, so the value is remembered and applied once it resolves.
|
|
71
71
|
* @inheritdoc
|
|
72
72
|
*/
|
|
73
|
-
|
|
73
|
+
setExpectedRequestProcessingTime(processingTimeSecs: number): Promise<void>;
|
|
74
74
|
/**
|
|
75
75
|
* Forwards a pacing signal to the writable manager - the loader side is read-only and dispatches nothing of
|
|
76
76
|
* its own. Only a resolved manager is signalled; the tandem will not open a queue to answer a question about
|
|
@@ -78,5 +78,5 @@ export declare class RequestManagerTandem implements IRequestManager {
|
|
|
78
78
|
* @inheritdoc
|
|
79
79
|
*/
|
|
80
80
|
recordPacingSignal(signal: PacingSignal): boolean;
|
|
81
|
-
|
|
81
|
+
extendRequestProcessingTime(request: Request, extensionSecs: number): Promise<boolean>;
|
|
82
82
|
}
|
|
@@ -12,7 +12,7 @@ export class RequestManagerTandem {
|
|
|
12
12
|
#resolvedRequestManager;
|
|
13
13
|
#requestManagerFactory;
|
|
14
14
|
/**
|
|
15
|
-
* The latest expected request-processing time hinted via {@link
|
|
15
|
+
* The latest expected request-processing time hinted via {@link setExpectedRequestProcessingTime}.
|
|
16
16
|
* Remembered so it can be applied to the writable manager once it is lazily resolved.
|
|
17
17
|
*/
|
|
18
18
|
#expectedRequestProcessingSecs;
|
|
@@ -43,7 +43,7 @@ export class RequestManagerTandem {
|
|
|
43
43
|
this.#resolvedRequestManager = await this.#requestManagerPromise;
|
|
44
44
|
// Apply any hint received before the manager was resolved.
|
|
45
45
|
if (this.#expectedRequestProcessingSecs !== undefined) {
|
|
46
|
-
await this.#resolvedRequestManager.
|
|
46
|
+
await this.#resolvedRequestManager.setExpectedRequestProcessingTime?.(this.#expectedRequestProcessingSecs);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
return this.#resolvedRequestManager;
|
|
@@ -181,9 +181,9 @@ export class RequestManagerTandem {
|
|
|
181
181
|
* reserved. The manager is opened lazily, so the value is remembered and applied once it resolves.
|
|
182
182
|
* @inheritdoc
|
|
183
183
|
*/
|
|
184
|
-
async
|
|
185
|
-
this.#expectedRequestProcessingSecs =
|
|
186
|
-
await this.#resolvedRequestManager?.
|
|
184
|
+
async setExpectedRequestProcessingTime(processingTimeSecs) {
|
|
185
|
+
this.#expectedRequestProcessingSecs = processingTimeSecs;
|
|
186
|
+
await this.#resolvedRequestManager?.setExpectedRequestProcessingTime?.(processingTimeSecs);
|
|
187
187
|
}
|
|
188
188
|
/**
|
|
189
189
|
* Forwards a pacing signal to the writable manager - the loader side is read-only and dispatches nothing of
|
|
@@ -194,7 +194,7 @@ export class RequestManagerTandem {
|
|
|
194
194
|
recordPacingSignal(signal) {
|
|
195
195
|
return this.#resolvedRequestManager?.recordPacingSignal(signal) ?? false;
|
|
196
196
|
}
|
|
197
|
-
async
|
|
198
|
-
return (await this.#getRequestManager()).
|
|
197
|
+
async extendRequestProcessingTime(request, extensionSecs) {
|
|
198
|
+
return (await this.#getRequestManager()).extendRequestProcessingTime?.(request, extensionSecs) ?? false;
|
|
199
199
|
}
|
|
200
200
|
}
|
|
@@ -30,7 +30,7 @@ export interface IRequestManager extends IRequestLoader {
|
|
|
30
30
|
* the same request out again while it is still being processed. Implementations that do not need
|
|
31
31
|
* this hint may leave it `undefined`.
|
|
32
32
|
*/
|
|
33
|
-
|
|
33
|
+
setExpectedRequestProcessingTime?(processingTimeSecs: number): Promise<void>;
|
|
34
34
|
/**
|
|
35
35
|
* Records something said about the pace requests should go out at, so that a manager which paces its own
|
|
36
36
|
* dispatch can hold requests back.
|
|
@@ -50,7 +50,7 @@ export interface IRequestManager extends IRequestLoader {
|
|
|
50
50
|
* requests or no longer holds this one; non-locking implementations may leave it `undefined`,
|
|
51
51
|
* which callers treat as `false`.
|
|
52
52
|
*/
|
|
53
|
-
|
|
53
|
+
extendRequestProcessingTime?(request: Request, extensionSecs: number): Promise<boolean>;
|
|
54
54
|
}
|
|
55
55
|
/**
|
|
56
56
|
* How much of the URL space a {@link PacingSignal} covers.
|
|
@@ -178,13 +178,13 @@ export declare class RequestQueue implements IStorage, IRequestManager {
|
|
|
178
178
|
* ever raise the reservation duration, never lower it — otherwise a short-lived consumer could cut
|
|
179
179
|
* short the reservation of a long-lived one and have its in-flight request stolen.
|
|
180
180
|
*/
|
|
181
|
-
|
|
181
|
+
setExpectedRequestProcessingTime(processingTimeSecs: number): Promise<void>;
|
|
182
182
|
/**
|
|
183
183
|
* @inheritdoc
|
|
184
|
-
* Unlike {@link RequestQueue.
|
|
184
|
+
* Unlike {@link RequestQueue.setExpectedRequestProcessingTime}, which sizes every future lock,
|
|
185
185
|
* this only touches the one request it is given.
|
|
186
186
|
*/
|
|
187
|
-
|
|
187
|
+
extendRequestProcessingTime(request: Request, extensionSecs: number): Promise<boolean>;
|
|
188
188
|
/**
|
|
189
189
|
* Removes the queue either from the Apify Cloud storage or from the local database,
|
|
190
190
|
* depending on the mode of operation.
|
|
@@ -110,7 +110,7 @@ export class RequestQueue {
|
|
|
110
110
|
#inProgressRequestBatchCount = 0;
|
|
111
111
|
/**
|
|
112
112
|
* The largest expected request-processing time (in seconds) seen so far via
|
|
113
|
-
* {@link
|
|
113
|
+
* {@link setExpectedRequestProcessingTime}. Used to ensure that value is only ever raised, never
|
|
114
114
|
* lowered, before being forwarded to the storage backend.
|
|
115
115
|
*/
|
|
116
116
|
#expectedRequestProcessingSecs = 0;
|
|
@@ -669,23 +669,23 @@ export class RequestQueue {
|
|
|
669
669
|
* ever raise the reservation duration, never lower it — otherwise a short-lived consumer could cut
|
|
670
670
|
* short the reservation of a long-lived one and have its in-flight request stolen.
|
|
671
671
|
*/
|
|
672
|
-
async
|
|
673
|
-
if (
|
|
672
|
+
async setExpectedRequestProcessingTime(processingTimeSecs) {
|
|
673
|
+
if (processingTimeSecs <= this.#expectedRequestProcessingSecs) {
|
|
674
674
|
return;
|
|
675
675
|
}
|
|
676
|
-
this.#expectedRequestProcessingSecs =
|
|
677
|
-
await this.backend.
|
|
676
|
+
this.#expectedRequestProcessingSecs = processingTimeSecs;
|
|
677
|
+
await this.backend.setExpectedRequestProcessingTime?.(processingTimeSecs);
|
|
678
678
|
}
|
|
679
679
|
/**
|
|
680
680
|
* @inheritdoc
|
|
681
|
-
* Unlike {@link RequestQueue.
|
|
681
|
+
* Unlike {@link RequestQueue.setExpectedRequestProcessingTime}, which sizes every future lock,
|
|
682
682
|
* this only touches the one request it is given.
|
|
683
683
|
*/
|
|
684
|
-
async
|
|
684
|
+
async extendRequestProcessingTime(request, extensionSecs) {
|
|
685
685
|
if (!request.id) {
|
|
686
686
|
return false;
|
|
687
687
|
}
|
|
688
|
-
return (await this.backend.
|
|
688
|
+
return (await this.backend.extendRequestProcessingTime?.(request.id, extensionSecs)) ?? false;
|
|
689
689
|
}
|
|
690
690
|
/**
|
|
691
691
|
* Caches information about request to beware of unneeded addRequest() calls.
|
|
@@ -722,7 +722,7 @@ export class RequestQueue {
|
|
|
722
722
|
this.#requestSeenCache.clear();
|
|
723
723
|
this.#inProgressRequestBatchCount = 0;
|
|
724
724
|
// Reset the expected-processing-time high-water mark too, otherwise the monotonic-raise guard
|
|
725
|
-
// in `
|
|
725
|
+
// in `setExpectedRequestProcessingTime` would let a value raised in an earlier run leak into a
|
|
726
726
|
// later one and silently swallow a lower hint (the queue is meant to be reusable across runs).
|
|
727
727
|
this.#expectedRequestProcessingSecs = 0;
|
|
728
728
|
}
|