Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion apps/webapp/app/routes/api.v1.artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,22 @@ export async function action({ request }: ActionFunctionArgs) {
switch (error.type) {
case "artifact_size_exceeds_limit": {
logger.warn("Artifact size exceeds limit", { error });
const sizeMB = parseFloat((error.contentLength / (1024 * 1024)).toFixed(1));
const limitMB = parseFloat((error.sizeLimit / (1024 * 1024)).toFixed(1));

let errorMessage;

switch (body.data.type) {
case "deployment_context":
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.`;
break;
default:
body.data.type satisfies never;
errorMessage = `Artifact size (${sizeMB} MB) exceeds the allowed limit of ${limitMB} MB`;
}
return json(
{
error: `Artifact size (${error.contentLength} bytes) exceeds the allowed limit of ${error.sizeLimit} bytes`,
error: errorMessage,
},
{ status: 400 }
);
Expand Down
8 changes: 4 additions & 4 deletions apps/webapp/app/v3/services/deployment.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,16 +410,16 @@ export class DeploymentService extends BaseService {
})
);

return getTokenFromCache()
.orElse(issueS2Token)
.andThen((token) =>
return getTokenFromCache().orElse(() =>
issueS2Token().andThen((token) =>
cacheToken(token)
.map(() => token)
.orElse((error) => {
logger.error("Failed to cache S2 token", { error });
return okAsync(token); // ignore the cache error
})
);
)
);
}

private getDeployment(projectId: string, friendlyId: string) {
Expand Down
19 changes: 13 additions & 6 deletions packages/cli-v3/src/commands/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -929,8 +929,9 @@ async function handleNativeBuildServerDeploy({
});

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

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

if (readError) {
$deploymentSpinner.stop("Failed to read deployment archive");
throw new Error(`Failed to read archive: ${readError.message}`);
$deploymentSpinner.stop("Failed reading deployment archive");
log.error(chalk.bold(chalkError(readError.message)));
throw new OutroCommandError(`Deployment failed`);
}

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

if (uploadError || !uploadResponse?.ok) {
$deploymentSpinner.stop("Failed to upload deployment files");
throw new Error(
`Failed to upload archive: ${uploadError?.message} ${uploadResponse?.status} ${uploadResponse?.statusText}`
log.error(
chalk.bold(
chalkError(
`${uploadError?.message} (${uploadResponse?.statusText} ${uploadResponse?.status})`
)
)
);
throw new OutroCommandError(`Deployment failed`);
}

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