We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Actor.exit()
1 parent 2eb6fef commit 483fc43Copy full SHA for 483fc43
packages/apify/src/actor.ts
@@ -553,6 +553,15 @@ export class Actor<Data extends Dictionary = Dictionary> {
553
log.debug(
554
`Waiting for all event listeners to complete their execution (with ${options.timeoutSecs} seconds timeout)`,
555
);
556
+
557
+ if (options.exit) {
558
+ // `addTimeoutToPromise` is a cooperative timeout. This ensures that the process exits
559
+ // after the timeout, even if the event listeners don't trigger the timeout.
560
+ setTimeout(() => {
561
+ process.exit(options.exitCode);
562
+ }, options.timeoutSecs * 1000);
563
+ }
564
565
await addTimeoutToPromise(
566
async () => {
567
await events.waitForAllListenersToComplete();
0 commit comments