Skip to content

Commit 271bc99

Browse files
authored
fix: prevent reboot loops (#345)
1 parent deda03b commit 271bc99

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

packages/apify/src/actor.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ export class Actor<Data extends Dictionary = Dictionary> {
8181
*/
8282
private warnedAboutMissingInitCall = false;
8383

84+
/**
85+
* Set if the Actor is currently rebooting.
86+
*/
87+
private isRebooting = false;
88+
8489
constructor(options: ConfigurationOptions = {}) {
8590
// use default configuration object if nothing overridden (it fallbacks to env vars)
8691
this.config = Object.keys(options).length === 0 ? Configuration.getGlobalConfig() : new Configuration(options);
@@ -459,6 +464,13 @@ export class Actor<Data extends Dictionary = Dictionary> {
459464
return;
460465
}
461466

467+
if (this.isRebooting) {
468+
log.debug('Actor is already rebooting, skipping the additional reboot call.');
469+
return;
470+
}
471+
472+
this.isRebooting = true;
473+
462474
// Waiting for all the listeners to finish, as `.reboot()` kills the container.
463475
await Promise.all([
464476
// `persistState` for individual RequestLists, RequestQueue... instances to be persisted

0 commit comments

Comments
 (0)