apify 4.0.0-beta.27 → 4.0.0-beta.29

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.d.ts CHANGED
@@ -318,6 +318,7 @@ export declare const EXIT_CODES: {
318
318
  * See {@link Configuration} for details about what can be configured and what are the default values.
319
319
  */
320
320
  export declare class Actor<Data extends Dictionary = Dictionary> {
321
+ #private;
321
322
  /** @internal */
322
323
  static _instance: Actor;
323
324
  /**
package/dist/actor.js CHANGED
@@ -70,6 +70,10 @@ export class Actor {
70
70
  * References to graceful shutdown handlers so they can be removed during cleanup.
71
71
  */
72
72
  gracefulShutdownHandlers = {};
73
+ /**
74
+ * Reference to the crawlee status message forwarder, so it can be removed during cleanup.
75
+ */
76
+ #statusMessageForwarder;
73
77
  chargingManager;
74
78
  /**
75
79
  * Tracks which aliased storages have been purged during this session,
@@ -242,6 +246,9 @@ export class Actor {
242
246
  };
243
247
  this.on(ACTOR_EVENT_NAMES.MIGRATING, this.gracefulShutdownHandlers.migrating);
244
248
  }
249
+ // Crawlee crawlers, for instance, broadcast their status messages as `statusMessage` events.
250
+ this.#statusMessageForwarder = async ({ message, isStatusMessageTerminal }) => this.#updateRunStatusMessage(message, isStatusMessageTerminal);
251
+ this.on(EventType.STATUS_MESSAGE, this.#statusMessageForwarder);
245
252
  await purgeDefaultStorages({
246
253
  configuration: this.configuration,
247
254
  onlyPurgeOnce: true,
@@ -293,6 +300,11 @@ export class Actor {
293
300
  }
294
301
  await addTimeoutToPromise(async () => {
295
302
  await events.waitForAllListenersToComplete();
303
+ // The final status messages have been forwarded by now; stop listening so
304
+ // that a periodic one can't overwrite the terminal message set below.
305
+ if (this.#statusMessageForwarder) {
306
+ this.off(EventType.STATUS_MESSAGE, this.#statusMessageForwarder);
307
+ }
296
308
  if (client.teardown) {
297
309
  let finished = false;
298
310
  setTimeout(() => {
@@ -591,6 +603,12 @@ export class Actor {
591
603
  log.info(loggedStatusMessage);
592
604
  break;
593
605
  }
606
+ return this.#updateRunStatusMessage(statusMessage, isStatusMessageTerminal);
607
+ }
608
+ /**
609
+ * Propagates a status message to the current run, without logging it locally.
610
+ */
611
+ async #updateRunStatusMessage(statusMessage, isStatusMessageTerminal) {
594
612
  const runId = this.configuration.actorRunId;
595
613
  if (runId) {
596
614
  // just to be sure, this should be fast
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apify",
3
- "version": "4.0.0-beta.27",
3
+ "version": "4.0.0-beta.29",
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"