Skip to content

Commit

Permalink
handle cloudflare 520 errors for file upload (#776)
Browse files Browse the repository at this point in the history
* handle cloudflare 520 errors for file upload

* 503 too
  • Loading branch information
mythmon authored Feb 13, 2024
1 parent ece88c5 commit 871b7bd
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,9 @@ class DeployBuildEffects implements BuildEffects {
try {
await this.apiClient.postDeployFile(this.deployId, sourcePath, outputPath);
} catch (error) {
if (isHttpError(error) && error.statusCode === 413) {
// 413 is "Payload Too Large", however sometimes Cloudflare returns a
// custom Cloudflare error, 520. Sometimes we also see 502. Handle them all
if (isHttpError(error) && (error.statusCode === 413 || error.statusCode === 503 || error.statusCode === 520)) {
throw new CliError(`File too large to deploy: ${sourcePath}. Maximum file size is 50MB.`, {cause: error});
}
throw error;
Expand Down

0 comments on commit 871b7bd

Please sign in to comment.