Skip to content

Commit

Permalink
fix: prevent reboot loops (#345)
Browse files Browse the repository at this point in the history
  • Loading branch information
fnesveda authored Dec 19, 2024
1 parent deda03b commit 271bc99
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/apify/src/actor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ export class Actor<Data extends Dictionary = Dictionary> {
*/
private warnedAboutMissingInitCall = false;

/**
* Set if the Actor is currently rebooting.
*/
private isRebooting = false;

constructor(options: ConfigurationOptions = {}) {
// use default configuration object if nothing overridden (it fallbacks to env vars)
this.config = Object.keys(options).length === 0 ? Configuration.getGlobalConfig() : new Configuration(options);
Expand Down Expand Up @@ -459,6 +464,13 @@ export class Actor<Data extends Dictionary = Dictionary> {
return;
}

if (this.isRebooting) {
log.debug('Actor is already rebooting, skipping the additional reboot call.');
return;
}

this.isRebooting = true;

// Waiting for all the listeners to finish, as `.reboot()` kills the container.
await Promise.all([
// `persistState` for individual RequestLists, RequestQueue... instances to be persisted
Expand Down

0 comments on commit 271bc99

Please sign in to comment.