apify 4.0.0-beta.147 → 4.0.0-beta.149
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/dist/actor.js
CHANGED
|
@@ -451,10 +451,27 @@ export class Actor {
|
|
|
451
451
|
// Like `ActorClient.call()`, but the run is recorded before it is waited for.
|
|
452
452
|
const { waitSecs, log, timeoutSecs = 'noTimeout', signal, ...startOptions } = rest;
|
|
453
453
|
const run = await this.#childRunTracker.startChildRun(client, abortWithParent, async () => client.actor(actorId).start(input, { ...startOptions, runTimeoutSecs, timeoutSecs, signal }));
|
|
454
|
-
|
|
454
|
+
return this.#waitForChildRun(client, run, { log, waitSecs, timeoutSecs, signal });
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* Waits for a child run to finish while its log is redirected, like `call()` of `apify-client`, and records the
|
|
458
|
+
* status it finished in.
|
|
459
|
+
*/
|
|
460
|
+
async #waitForChildRun(client, run, { log: toLog, ...waitOptions }) {
|
|
461
|
+
const runClient = client.run(run.id);
|
|
462
|
+
let streamedLog;
|
|
463
|
+
try {
|
|
464
|
+
streamedLog = await runClient.getStreamedLog({ toLog, signal: waitOptions.signal });
|
|
465
|
+
}
|
|
466
|
+
catch (error) {
|
|
467
|
+
// An aborted call rejects with the reason of its signal, which the wait below takes care of.
|
|
468
|
+
if (!waitOptions.signal?.aborted) {
|
|
469
|
+
log.warning(`Waiting for run ${run.id} without log redirection, which could not be set up: ${error.message}`);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
455
472
|
streamedLog?.start();
|
|
456
473
|
try {
|
|
457
|
-
const finishedRun = await
|
|
474
|
+
const finishedRun = await runClient.waitForFinish(waitOptions);
|
|
458
475
|
await this.#childRunTracker.update(finishedRun);
|
|
459
476
|
return finishedRun;
|
|
460
477
|
}
|
|
@@ -570,11 +587,9 @@ export class Actor {
|
|
|
570
587
|
const { token, timeout: _timeout, abortWithParent = false, ...rest } = options;
|
|
571
588
|
const client = token ? this.newClient({ token }) : this.apifyClient;
|
|
572
589
|
// Like `TaskClient.call()`, but the run is recorded before it is waited for.
|
|
573
|
-
const { waitSecs, timeoutSecs = 'noTimeout', signal, ...startOptions } = rest;
|
|
590
|
+
const { waitSecs, log, timeoutSecs = 'noTimeout', signal, ...startOptions } = rest;
|
|
574
591
|
const run = await this.#childRunTracker.startChildRun(client, abortWithParent, async () => client.task(taskId).start(input, { ...startOptions, runTimeoutSecs, timeoutSecs, signal }));
|
|
575
|
-
|
|
576
|
-
await this.#childRunTracker.update(finishedRun);
|
|
577
|
-
return finishedRun;
|
|
592
|
+
return this.#waitForChildRun(client, run, { log, waitSecs, timeoutSecs, signal });
|
|
578
593
|
}
|
|
579
594
|
/**
|
|
580
595
|
* Returns a client for each child run started by `Actor.start()`, `Actor.call()`, `Actor.startTask()` or
|
|
@@ -52,7 +52,7 @@ export declare class ApifyStorageBackend implements StorageBackend {
|
|
|
52
52
|
getStorageBackendCacheKey(): string;
|
|
53
53
|
/** Lets crawlee's storage load signal see the API's rate-limit errors. */
|
|
54
54
|
get stats(): StorageBackend['stats'];
|
|
55
|
-
/** Short digest of the API base URL and token — identifies the credentials
|
|
55
|
+
/** Short digest of the API base URL and `identity`, the token unless given — identifies the credentials. */
|
|
56
56
|
private credentialsHash;
|
|
57
57
|
storageExists(id: string, type: StorageType): Promise<boolean>;
|
|
58
58
|
createDatasetBackend(options?: StorageIdentifier): Promise<DatasetBackend>;
|
|
@@ -77,10 +77,10 @@ export class ApifyStorageBackend {
|
|
|
77
77
|
get stats() {
|
|
78
78
|
return this.#client.stats;
|
|
79
79
|
}
|
|
80
|
-
/** Short digest of the API base URL and token — identifies the credentials
|
|
81
|
-
credentialsHash() {
|
|
80
|
+
/** Short digest of the API base URL and `identity`, the token unless given — identifies the credentials. */
|
|
81
|
+
credentialsHash(identity) {
|
|
82
82
|
return createHash('sha256')
|
|
83
|
-
.update(`${this.#client.publicBaseUrl}${this.#client.token
|
|
83
|
+
.update(`${this.#client.publicBaseUrl}${identity || this.#client.token || ''}`)
|
|
84
84
|
.digest('hex')
|
|
85
85
|
.slice(0, 8);
|
|
86
86
|
}
|
|
@@ -148,8 +148,10 @@ export class ApifyStorageBackend {
|
|
|
148
148
|
*/
|
|
149
149
|
async resolveAliasId(alias, type) {
|
|
150
150
|
// The credentials are part of the key, so the same alias opened through two
|
|
151
|
-
// differently-authenticated backends maps to two storages.
|
|
152
|
-
|
|
151
|
+
// differently-authenticated backends maps to two storages. The platform issues a new run token
|
|
152
|
+
// on migration, reboot and resurrection, so the run's own token is identified by its user.
|
|
153
|
+
const runUserId = this.#client.token === this.#config?.token ? this.#config?.userId : undefined;
|
|
154
|
+
const key = [type, alias, this.credentialsHash(runUserId)].join(',');
|
|
153
155
|
return this.#aliasLock.runExclusive(async () => {
|
|
154
156
|
const store = this.aliasMappingStore();
|
|
155
157
|
this.#persistedAliasIds ??= store ? await readAliasMapping(store) : {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "apify",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.149",
|
|
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"
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"@crawlee/fs-storage": "4.0.0-beta.348",
|
|
66
66
|
"@crawlee/types": "4.0.0-beta.348",
|
|
67
67
|
"@crawlee/utils": "4.0.0-beta.348",
|
|
68
|
-
"apify-client": "
|
|
68
|
+
"apify-client": "3.0.0-beta.127",
|
|
69
69
|
"minimatch": "^11.0.10",
|
|
70
70
|
"tslib": "^2.9.1",
|
|
71
71
|
"ws": "^8.23.1",
|