Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading