Skip to content
Open
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions src/commands/actors/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,13 @@ Skipping push. Use --force to override.`,
run({ message: `Created version ${version} 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
run({ message: `Building Actor ${actor.name}` });
let build = await actorClient.build(version, {
Expand Down
25 changes: 18 additions & 7 deletions test/api/commands/push.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 sync standby mode on existing actor based on usesStandbyMode in actor.json',
async () => {
// Create an actor without standby mode first
const testActorWithTitleDesc = {
Expand All @@ -422,23 +422,34 @@ describe('[api] apify push', () => {
const initialActor = await testActorClient.get();
expect(initialActor?.actorStandby?.isEnabled).to.not.be.eql(true);

// Enable standby
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 update 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' });
resetCwdCaches();
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 not enabled after push
expect(updatedActor?.actorStandby?.isEnabled).to.not.be.eql(true);
if (updatedActor) await testActorClient.delete();
if (disabledActor) await testActorClient.delete();
},
TEST_TIMEOUT,
);
Expand Down