Skip to content
Merged
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"@skyra/jaro-winkler": "^1.1.1",
"adm-zip": "~0.5.15",
"ajv": "~8.17.1",
"apify-client": "~2.22.0",
"apify-client": "^2.22.0",
"archiver": "~7.0.1",
"axios": "^1.11.0",
"chalk": "~5.6.0",
Expand Down
6 changes: 6 additions & 0 deletions src/commands/actors/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,12 @@ export class ActorsPushCommand extends ApifyCommand<typeof ActorsPushCommand> {
},
],
};

// Enable standby mode if configured in actor.json
if (actorConfig!.usesStandbyMode) {
newActor.actorStandby = { isEnabled: true };
}
Comment on lines +202 to +205
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just calling out, not blocking: This will only enable standby on new actors, and it will NOT propagate to existing ones (say if you migrate from ??? -> standby, or vice versa)

Maybe this is something we want to do? @B4nan Or should it be a different command, like actors edit?

Copy link
Member

@B4nan B4nan Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, good point, no strong opinions, I wouldn't add a new command for that (we don't have actors edit, or do we?)

(I wouldn't block the PR on that, it can happen in a future one, or even never if nobody really asks for it)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, there are other cases already where changing something in the actor.json file for an existing Actor doesn't change the "platform-side version" of the Actor, so... Ostrich algorithm?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah agreed, lets leave that for later never.


actor = await apifyClient.actors().create(newActor);
actorId = actor.id;
isActorCreatedNow = true;
Expand Down
73 changes: 72 additions & 1 deletion test/api/commands/push.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,6 @@ describe('[api] apify push', () => {
await testRunCommand(ActorsPushCommand, { args_actorId: testActor.id, flags_noPrompt: true });

testActor = (await testActorClient.get())!;

if (testActor) await testActorClient.delete();

// Title and description should be preserved from the original actor
Expand All @@ -372,6 +371,78 @@ describe('[api] apify push', () => {
TEST_TIMEOUT,
);

it(
'should enable standby mode when usesStandbyMode is true in actor.json',
async () => {
const actorJson = JSON.parse(readFileSync(joinPath(LOCAL_CONFIG_PATH), 'utf8'));

actorJson.name = `${actorJson.name}-standBy-test`;
actorJson.usesStandbyMode = true;

writeFileSync(joinPath(LOCAL_CONFIG_PATH), JSON.stringify(actorJson, null, '\t'), { flag: 'w' });

await testRunCommand(ActorsPushCommand, { flags_noPrompt: true, flags_force: true });

const userInfo = await getLocalUserInfo();
const actorId = `${userInfo.username}/${actorJson.name}`;
actorsForCleanup.add(actorId);
const createdActorClient = testUserClient.actor(actorId);
const createdActor = await createdActorClient.get();

// Verify all standby options are set to default values
expect(createdActor?.actorStandby).to.be.eql({
isEnabled: true,
disableStandbyFieldsOverride: false,
maxRequestsPerActorRun: 4,
desiredRequestsPerActorRun: 3,
idleTimeoutSecs: 300,
build: 'latest',
memoryMbytes: 1024,
shouldPassActorInput: false,
});

if (createdActor) await createdActorClient.delete();
},
TEST_TIMEOUT,
);

it(
'should not enable standby mode on existing actor when usesStandbyMode is true in actor.json',
async () => {
// Create an actor without standby mode first
const testActorWithTitleDesc = {
...TEST_ACTOR,
name: `${TEST_ACTOR.name}-standBy-rewrite-test`,
};
const testActor = await testUserClient.actors().create(testActorWithTitleDesc);
actorsForCleanup.add(testActor.id);
const testActorClient = testUserClient.actor(testActor.id);

// Verify standby is not enabled initially
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'));
actorJson.usesStandbyMode = true;
writeFileSync(joinPath(LOCAL_CONFIG_PATH), JSON.stringify(actorJson, null, '\t'), { flag: 'w' });

// Push to existing actor - this should update standby mode
await testRunCommand(ActorsPushCommand, {
args_actorId: testActor.id,
flags_noPrompt: true,
flags_force: true,
});

const updatedActor = await testActorClient.get();

// Verify standby is not enabled after push
expect(updatedActor?.actorStandby?.isEnabled).to.not.be.eql(true);
if (updatedActor) await testActorClient.delete();
},
TEST_TIMEOUT,
);

it(
'should not push Actor when there are no files to push',
async () => {
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2300,7 +2300,7 @@ __metadata:
adm-zip: "npm:~0.5.15"
ajv: "npm:~8.17.1"
apify: "npm:^3.2.4"
apify-client: "npm:~2.22.0"
apify-client: "npm:^2.22.0"
archiver: "npm:~7.0.1"
axios: "npm:^1.11.0"
chalk: "npm:~5.6.0"
Expand Down Expand Up @@ -2368,7 +2368,7 @@ __metadata:
languageName: node
linkType: hard

"apify-client@npm:~2.22.0":
"apify-client@npm:^2.22.0":
version: 2.22.0
resolution: "apify-client@npm:2.22.0"
dependencies:
Expand Down