Skip to content

Commit fca7c58

Browse files
authored
fix: enable standby mode on actors during push when usesStandbyMode is set (#1016)
1 parent 40161bf commit fca7c58

2 files changed

Lines changed: 25 additions & 7 deletions

File tree

src/commands/actors/push.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,13 @@ Skipping push. Use --force to override.`,
318318
run({ message: `Created version ${version} for Actor ${actor.name}.` });
319319
}
320320

321+
// Sync standby mode on existing actors with actor.json
322+
if (!isActorCreatedNow && !!actorConfig!.usesStandbyMode !== !!actor.actorStandby?.isEnabled) {
323+
const isEnabled = !!actorConfig!.usesStandbyMode;
324+
await actorClient.update({ actorStandby: { isEnabled } });
325+
info({ message: `${isEnabled ? 'Enabled' : 'Disabled'} standby mode for Actor ${actor.name}.` });
326+
}
327+
321328
// Build Actor on Apify and wait for build to finish
322329
run({ message: `Building Actor ${actor.name}` });
323330
let build = await actorClient.build(version, {

test/api/commands/push.test.ts

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ describe('[api] apify push', () => {
407407
);
408408

409409
it(
410-
'should not enable standby mode on existing actor when usesStandbyMode is true in actor.json',
410+
'should sync standby mode on existing actor based on usesStandbyMode in actor.json',
411411
async () => {
412412
// Create an actor without standby mode first
413413
const testActorWithTitleDesc = {
@@ -422,23 +422,34 @@ describe('[api] apify push', () => {
422422
const initialActor = await testActorClient.get();
423423
expect(initialActor?.actorStandby?.isEnabled).to.not.be.eql(true);
424424

425-
// Enable standby
426425
const actorJson = JSON.parse(readFileSync(joinPath(LOCAL_CONFIG_PATH), 'utf8'));
426+
427+
// Enable standby in actor.json and push
427428
actorJson.usesStandbyMode = true;
428429
writeFileSync(joinPath(LOCAL_CONFIG_PATH), JSON.stringify(actorJson, null, '\t'), { flag: 'w' });
430+
await testRunCommand(ActorsPushCommand, {
431+
args_actorId: testActor.id,
432+
flags_noPrompt: true,
433+
flags_force: true,
434+
});
429435

430-
// Push to existing actor - this should update standby mode
436+
const enabledActor = await testActorClient.get();
437+
expect(enabledActor?.actorStandby?.isEnabled).to.be.eql(true);
438+
439+
// Remove usesStandbyMode from actor.json and push again (should disable)
440+
delete actorJson.usesStandbyMode;
441+
writeFileSync(joinPath(LOCAL_CONFIG_PATH), JSON.stringify(actorJson, null, '\t'), { flag: 'w' });
442+
resetCwdCaches();
431443
await testRunCommand(ActorsPushCommand, {
432444
args_actorId: testActor.id,
433445
flags_noPrompt: true,
434446
flags_force: true,
435447
});
436448

437-
const updatedActor = await testActorClient.get();
449+
const disabledActor = await testActorClient.get();
450+
expect(disabledActor?.actorStandby?.isEnabled).to.be.eql(false);
438451

439-
// Verify standby is not enabled after push
440-
expect(updatedActor?.actorStandby?.isEnabled).to.not.be.eql(true);
441-
if (updatedActor) await testActorClient.delete();
452+
if (disabledActor) await testActorClient.delete();
442453
},
443454
TEST_TIMEOUT,
444455
);

0 commit comments

Comments
 (0)