diff --git a/src/commands/actors/push.ts b/src/commands/actors/push.ts index 5b6683714..591123739 100644 --- a/src/commands/actors/push.ts +++ b/src/commands/actors/push.ts @@ -315,6 +315,12 @@ Skipping push. Use --force to override.`, run({ message: `Created version ${version} for Actor ${actor.name}.` }); } + // Enable standby mode on existing actors if configured in actor.json + if (!isActorCreatedNow && actorConfig!.usesStandbyMode && !actor.actorStandby?.isEnabled) { + await actorClient.update({ actorStandby: { isEnabled: true } }); + info({ message: `Enabled standby mode for Actor ${actor.name}.` }); + } + // Build Actor on Apify and wait for build to finish run({ message: `Building Actor ${actor.name}` }); let build = await actorClient.build(version, { diff --git a/test/api/commands/push.test.ts b/test/api/commands/push.test.ts index 1fca6f3ad..35f65ba3a 100644 --- a/test/api/commands/push.test.ts +++ b/test/api/commands/push.test.ts @@ -407,7 +407,7 @@ describe('[api] apify push', () => { ); it( - 'should not enable standby mode on existing actor when usesStandbyMode is true in actor.json', + 'should enable standby mode on existing actor when usesStandbyMode is true in actor.json', async () => { // Create an actor without standby mode first const testActorWithTitleDesc = { @@ -422,12 +422,12 @@ describe('[api] apify push', () => { const initialActor = await testActorClient.get(); expect(initialActor?.actorStandby?.isEnabled).to.not.be.eql(true); - // Enable standby + // Enable standby in actor.json const actorJson = JSON.parse(readFileSync(joinPath(LOCAL_CONFIG_PATH), 'utf8')); actorJson.usesStandbyMode = true; writeFileSync(joinPath(LOCAL_CONFIG_PATH), JSON.stringify(actorJson, null, '\t'), { flag: 'w' }); - // Push to existing actor - this should update standby mode + // Push to existing actor - this should enable standby mode await testRunCommand(ActorsPushCommand, { args_actorId: testActor.id, flags_noPrompt: true, @@ -436,8 +436,8 @@ describe('[api] apify push', () => { const updatedActor = await testActorClient.get(); - // Verify standby is not enabled after push - expect(updatedActor?.actorStandby?.isEnabled).to.not.be.eql(true); + // Verify standby is enabled after push + expect(updatedActor?.actorStandby?.isEnabled).to.be.eql(true); if (updatedActor) await testActorClient.delete(); }, TEST_TIMEOUT,