From b25dd40cde8c024df43b66db56d3b1e2caebb532 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 10 Feb 2026 13:02:59 +0000 Subject: [PATCH 1/2] fix: enable standby mode on existing actors when usesStandbyMode is true in actor.json Previously, `apify push` only set actorStandby when creating a brand new actor. When pushing to an existing actor (the common case), usesStandbyMode from actor.json was completely ignored. This adds an actor update call after version update/create to enable standby mode on existing actors. https://claude.ai/code/session_011wdJEiBvW5AtjfL5CRNdsM --- src/commands/actors/push.ts | 6 ++++++ test/api/commands/push.test.ts | 10 +++++----- 2 files changed, 11 insertions(+), 5 deletions(-) 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, From d3696905d20cb94ed09842b2f54a0a3d8aa31875 Mon Sep 17 00:00:00 2001 From: MQ37 Date: Thu, 26 Feb 2026 12:35:20 +0100 Subject: [PATCH 2/2] fix: make standby mode sync bidirectional during push actor.json is now the source of truth for standby mode. When pushing to an existing actor, standby is enabled when usesStandbyMode is true and disabled when it is false or absent. Previously only enabling was supported, causing config drift. --- src/commands/actors/push.ts | 9 +++++---- test/api/commands/push.test.ts | 24 +++++++++++++++++------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/commands/actors/push.ts b/src/commands/actors/push.ts index 591123739..e77614084 100644 --- a/src/commands/actors/push.ts +++ b/src/commands/actors/push.ts @@ -315,10 +315,11 @@ 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}.` }); + // Sync standby mode on existing actors with actor.json + if (!isActorCreatedNow && !!actorConfig!.usesStandbyMode !== !!actor.actorStandby?.isEnabled) { + const isEnabled = !!actorConfig!.usesStandbyMode; + await actorClient.update({ actorStandby: { isEnabled } }); + info({ message: `${isEnabled ? 'Enabled' : 'Disabled'} standby mode for Actor ${actor.name}.` }); } // Build Actor on Apify and wait for build to finish diff --git a/test/api/commands/push.test.ts b/test/api/commands/push.test.ts index 35f65ba3a..3aa9607be 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 enable standby mode on existing actor when usesStandbyMode is true in actor.json', + 'should sync standby mode on existing actor based on usesStandbyMode in actor.json', async () => { // Create an actor without standby mode first const testActorWithTitleDesc = { @@ -422,23 +422,33 @@ describe('[api] apify push', () => { const initialActor = await testActorClient.get(); expect(initialActor?.actorStandby?.isEnabled).to.not.be.eql(true); - // Enable standby in actor.json const actorJson = JSON.parse(readFileSync(joinPath(LOCAL_CONFIG_PATH), 'utf8')); + + // Enable standby in actor.json and push actorJson.usesStandbyMode = true; writeFileSync(joinPath(LOCAL_CONFIG_PATH), JSON.stringify(actorJson, null, '\t'), { flag: 'w' }); + await testRunCommand(ActorsPushCommand, { + args_actorId: testActor.id, + flags_noPrompt: true, + flags_force: true, + }); - // Push to existing actor - this should enable standby mode + const enabledActor = await testActorClient.get(); + expect(enabledActor?.actorStandby?.isEnabled).to.be.eql(true); + + // Remove usesStandbyMode from actor.json and push again (should disable) + delete actorJson.usesStandbyMode; + writeFileSync(joinPath(LOCAL_CONFIG_PATH), JSON.stringify(actorJson, null, '\t'), { flag: 'w' }); await testRunCommand(ActorsPushCommand, { args_actorId: testActor.id, flags_noPrompt: true, flags_force: true, }); - const updatedActor = await testActorClient.get(); + const disabledActor = await testActorClient.get(); + expect(disabledActor?.actorStandby?.isEnabled).to.be.eql(false); - // Verify standby is enabled after push - expect(updatedActor?.actorStandby?.isEnabled).to.be.eql(true); - if (updatedActor) await testActorClient.delete(); + if (disabledActor) await testActorClient.delete(); }, TEST_TIMEOUT, );