Skip to content

Commit 4dc9564

Browse files
authored
fix(deployments): misc fixes for the native build server deployment flow (#2748)
Improved a couple of error messages. Also fixed an issue with the s2 token caching.
1 parent 7fddadc commit 4dc9564

File tree

3 files changed

+31
-11
lines changed

3 files changed

+31
-11
lines changed

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,22 @@ export async function action({ request }: ActionFunctionArgs) {
5252
switch (error.type) {
5353
case "artifact_size_exceeds_limit": {
5454
logger.warn("Artifact size exceeds limit", { error });
55+
const sizeMB = parseFloat((error.contentLength / (1024 * 1024)).toFixed(1));
56+
const limitMB = parseFloat((error.sizeLimit / (1024 * 1024)).toFixed(1));
57+
58+
let errorMessage;
59+
60+
switch (body.data.type) {
61+
case "deployment_context":
62+
errorMessage = `Artifact size (${sizeMB} MB) exceeds the allowed limit of ${limitMB} MB. Make sure you are in the correct directory of your Trigger.dev project. Reach out to us if you are seeing this error consistently.`;
63+
break;
64+
default:
65+
body.data.type satisfies never;
66+
errorMessage = `Artifact size (${sizeMB} MB) exceeds the allowed limit of ${limitMB} MB`;
67+
}
5568
return json(
5669
{
57-
error: `Artifact size (${error.contentLength} bytes) exceeds the allowed limit of ${error.sizeLimit} bytes`,
70+
error: errorMessage,
5871
},
5972
{ status: 400 }
6073
);

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -410,16 +410,16 @@ export class DeploymentService extends BaseService {
410410
})
411411
);
412412

413-
return getTokenFromCache()
414-
.orElse(issueS2Token)
415-
.andThen((token) =>
413+
return getTokenFromCache().orElse(() =>
414+
issueS2Token().andThen((token) =>
416415
cacheToken(token)
417416
.map(() => token)
418417
.orElse((error) => {
419418
logger.error("Failed to cache S2 token", { error });
420419
return okAsync(token); // ignore the cache error
421420
})
422-
);
421+
)
422+
);
423423
}
424424

425425
private getDeployment(projectId: string, friendlyId: string) {

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

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -929,8 +929,9 @@ async function handleNativeBuildServerDeploy({
929929
});
930930

931931
if (!artifactResult.success) {
932-
$deploymentSpinner.stop("Failed to upload deployment files");
933-
throw new Error(`Failed to create deployment artifact: ${artifactResult.error}`);
932+
$deploymentSpinner.stop("Failed creating deployment artifact");
933+
log.error(chalk.bold(chalkError(artifactResult.error)));
934+
throw new OutroCommandError(`Deployment failed`);
934935
}
935936

936937
const { artifactKey, uploadUrl, uploadFields } = artifactResult.data;
@@ -942,8 +943,9 @@ async function handleNativeBuildServerDeploy({
942943
const [readError, fileBuffer] = await tryCatch(readFile(archivePath));
943944

944945
if (readError) {
945-
$deploymentSpinner.stop("Failed to read deployment archive");
946-
throw new Error(`Failed to read archive: ${readError.message}`);
946+
$deploymentSpinner.stop("Failed reading deployment archive");
947+
log.error(chalk.bold(chalkError(readError.message)));
948+
throw new OutroCommandError(`Deployment failed`);
947949
}
948950

949951
const formData = new FormData();
@@ -964,9 +966,14 @@ async function handleNativeBuildServerDeploy({
964966

965967
if (uploadError || !uploadResponse?.ok) {
966968
$deploymentSpinner.stop("Failed to upload deployment files");
967-
throw new Error(
968-
`Failed to upload archive: ${uploadError?.message} ${uploadResponse?.status} ${uploadResponse?.statusText}`
969+
log.error(
970+
chalk.bold(
971+
chalkError(
972+
`${uploadError?.message} (${uploadResponse?.statusText} ${uploadResponse?.status})`
973+
)
974+
)
969975
);
976+
throw new OutroCommandError(`Deployment failed`);
970977
}
971978

972979
const [unlinkError] = await tryCatch(unlink(archivePath));

0 commit comments

Comments
 (0)