diff --git a/apps/webapp/app/routes/api.v1.artifacts.ts b/apps/webapp/app/routes/api.v1.artifacts.ts index f0ff332812..82ae3f5375 100644 --- a/apps/webapp/app/routes/api.v1.artifacts.ts +++ b/apps/webapp/app/routes/api.v1.artifacts.ts @@ -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 } ); diff --git a/apps/webapp/app/v3/services/deployment.server.ts b/apps/webapp/app/v3/services/deployment.server.ts index ec9ea293af..11d659ab22 100644 --- a/apps/webapp/app/v3/services/deployment.server.ts +++ b/apps/webapp/app/v3/services/deployment.server.ts @@ -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) { diff --git a/packages/cli-v3/src/commands/deploy.ts b/packages/cli-v3/src/commands/deploy.ts index 0a18e3ea70..d387c83d65 100644 --- a/packages/cli-v3/src/commands/deploy.ts +++ b/packages/cli-v3/src/commands/deploy.ts @@ -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; @@ -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(); @@ -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));