Skip to content

Commit 2417940

Browse files
kristof-siketclaude
andcommitted
fix(app): cache the actual live deployment after --no-promote
setKnownLiveDeployment cached the un-promoted candidate as the known-live deployment; with --no-promote that id is not live. Cache the actually-live id instead (the previous deployment that keeps serving), and skip the write when the app has no live deployment yet. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 0e29f9c commit 2417940

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

packages/cli/src/controllers/app.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -823,11 +823,18 @@ async function runSingleAppDeploy(
823823
id: deployResult.app.id,
824824
name: deployResult.app.name,
825825
});
826-
await context.stateStore.setKnownLiveDeployment(
827-
projectId,
828-
deployResult.app.id,
829-
deployResult.deployment.id,
830-
);
826+
// With --no-promote the live deployment is unchanged, so cache the actually-live
827+
// id (never the un-promoted candidate); skip when the app has nothing live yet.
828+
const knownLiveDeploymentId = deployResult.promoted
829+
? deployResult.deployment.id
830+
: deployResult.app.liveDeploymentId;
831+
if (knownLiveDeploymentId) {
832+
await context.stateStore.setKnownLiveDeployment(
833+
projectId,
834+
deployResult.app.id,
835+
knownLiveDeploymentId,
836+
);
837+
}
831838

832839
return {
833840
command: "app.deploy",

packages/cli/tests/app-controller.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7037,6 +7037,11 @@ describe("app controller", () => {
70377037
"prisma-cli app promote dep_candidate",
70387038
"prisma-cli app show-deploy dep_candidate",
70397039
]);
7040+
// The un-promoted candidate must not be cached as the known-live deployment;
7041+
// the previously-live one keeps serving.
7042+
expect(
7043+
await context.stateStore.readKnownLiveDeployment("proj_123", "app_1"),
7044+
).toBe("dep_live");
70407045
});
70417046

70427047
it("deploy --no-promote on the production branch bypasses the production gate", async () => {

0 commit comments

Comments
 (0)