Skip to content

Commit 4a1ebb1

Browse files
committed
refactor(core,cli,webapp): drop the build env vars stored ack
An older server without build env var support fails the build on the server side with a clear error, so the client-side ack guard, the courtesy cancel, and the client-side limit pre-checks are unnecessary.
1 parent 140e4b3 commit 4a1ebb1

5 files changed

Lines changed: 0 additions & 68 deletions

File tree

apps/webapp/app/routes/api.v1.deployments.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ export async function action({ request, params }: ActionFunctionArgs) {
6060
.externalBuildData as InitializeDeploymentResponseBody["externalBuildData"],
6161
eventStream: result.eventStream,
6262
canceledDeployments: result.canceledDeployments,
63-
...(result.buildEnvVarsStored ? { buildEnvVarsStored: true } : {}),
6463
}
6564
: { isPromoted: result.isPromoted }),
6665
};

apps/webapp/app/v3/services/initializeDeployment.server.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ export type InitializeDeploymentResult =
4545
imageRef: string;
4646
eventStream?: DeploymentEventStream;
4747
canceledDeployments?: SupersededDeployment[];
48-
buildEnvVarsStored?: boolean;
4948
}
5049
| {
5150
outcome: "existing";
@@ -105,7 +104,6 @@ export class InitializeDeploymentService extends BaseService {
105104
outcome: "created",
106105
deployment: existingDeployment,
107106
imageRef: existingDeployment.imageReference ?? "",
108-
buildEnvVarsStored: false,
109107
};
110108
}
111109

@@ -445,7 +443,6 @@ export class InitializeDeploymentService extends BaseService {
445443
imageRef: deployment.imageReference ?? "",
446444
eventStream,
447445
canceledDeployments,
448-
buildEnvVarsStored: encryptedBuildEnvVars !== undefined,
449446
};
450447
});
451448
}

packages/cli-v3/src/apiClient.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -690,19 +690,6 @@ export class CliApiClient {
690690
);
691691
}
692692

693-
// 204 on success, no body
694-
async cancelDeployment(deploymentId: string, reason?: string) {
695-
if (!this.accessToken) {
696-
throw new Error("cancelDeployment: No access token");
697-
}
698-
699-
return fetch(`${this.apiURL}/api/v1/deployments/${deploymentId}/cancel`, {
700-
method: "POST",
701-
headers: this.getHeaders(),
702-
body: JSON.stringify({ reason }),
703-
});
704-
}
705-
706693
async getDeploymentBuildEnvVars(deploymentId: string) {
707694
if (!this.accessToken) {
708695
throw new Error("getDeploymentBuildEnvVars: No access token");

packages/cli-v3/src/commands/deploy.ts

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,6 @@ type DeployCommandOptions = z.infer<typeof DeployCommandOptions>;
105105

106106
type Deployment = InitializeDeploymentResponseBody;
107107

108-
// Pre-checks of the server-enforced limits, to fail before uploading anything
109-
const BUILD_ENV_VARS_MAX_BYTES = 128 * 1024;
110-
const BUILD_ENV_VARS_MAX_KEYS = 200;
111-
112108
export function configureDeployCommand(program: Command) {
113109
return (
114110
commonOptions(
@@ -1364,21 +1360,6 @@ async function handleNativeBuildServerDeploy({
13641360
)
13651361
);
13661362

1367-
const buildEnvVarCount = Object.keys(bundleBuildEnvVars).length;
1368-
const buildEnvVarBytes = Buffer.byteLength(JSON.stringify(bundleBuildEnvVars), "utf8");
1369-
1370-
if (buildEnvVarCount > BUILD_ENV_VARS_MAX_KEYS) {
1371-
throw new Error(
1372-
`Your build uses too many build environment variables: ${buildEnvVarCount} (max ${BUILD_ENV_VARS_MAX_KEYS}).`
1373-
);
1374-
}
1375-
1376-
if (buildEnvVarBytes > BUILD_ENV_VARS_MAX_BYTES) {
1377-
throw new Error(
1378-
`Your build environment variables are too large: ${buildEnvVarBytes} bytes (max ${BUILD_ENV_VARS_MAX_BYTES}). Reduce the size of the env var values used by your build.`
1379-
);
1380-
}
1381-
13821363
if (options.dryRun) {
13831364
logger.info(`Dry run complete. View the built bundle at ${destination.path}`);
13841365
return;
@@ -1567,36 +1548,6 @@ async function handleNativeBuildServerDeploy({
15671548
return;
15681549
}
15691550

1570-
// No ack for sent build env vars means an older server stripped them; fail fast.
1571-
// After the outcome=existing return: a reused deployment builds nothing.
1572-
if (
1573-
options.localBundle &&
1574-
bundleBuildEnvVars &&
1575-
Object.keys(bundleBuildEnvVars).length > 0 &&
1576-
!deployment.buildEnvVarsStored
1577-
) {
1578-
// Best-effort cancel so the deployment does not linger until the queue timeout
1579-
const [cancelError] = await tryCatch(
1580-
apiClient.cancelDeployment(deployment.id, "Build environment variables were not stored")
1581-
);
1582-
if (cancelError) {
1583-
logger.debug("Failed to cancel deployment after missing build env vars ack", {
1584-
deploymentId: deployment.id,
1585-
error: cancelError,
1586-
});
1587-
}
1588-
1589-
$deploymentSpinner.stop("Failed to initialize deployment");
1590-
log.error(
1591-
chalk.bold(
1592-
chalkError(
1593-
"This server does not support --local-bundle deploys with build environment variables yet. Deploy without --local-bundle instead."
1594-
)
1595-
)
1596-
);
1597-
throw new OutroCommandError(`Deployment failed`);
1598-
}
1599-
16001551
const exposedDeploymentLink = isLinksSupported
16011552
? cliLink(chalk.bold(rawDeploymentLink), rawDeploymentLink)
16021553
: chalk.bold(rawDeploymentLink);

packages/core/src/v3/schemas/api.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -758,8 +758,6 @@ export const InitializeDeploymentResponseBody = z.object({
758758
}),
759759
})
760760
.optional(),
761-
// Ack that buildEnvVars were stored; absence on an older server is a client-side hard error
762-
buildEnvVarsStored: z.boolean().optional(),
763761
});
764762

765763
export type InitializeDeploymentResponseBody = z.infer<typeof InitializeDeploymentResponseBody>;

0 commit comments

Comments
 (0)