diff --git a/CHANGELOG.md b/CHANGELOG.md index 092f67a73d..16d4bc734c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ This is the log of notable changes to EAS CLI and related packages. - Show `eas deploy` upload error messages. ([#2771](https://github.com/expo/eas-cli/pull/2771) by [@kadikraman](https://github.com/kadikraman)) - Prevent EAS CLI dependencies check from running repeatedly. ([#2781](https://github.com/expo/eas-cli/pull/2781) by [@kitten](https://github.com/kitten)) +- Prevent optimistic request body parsing for `eas deploy`. ([#2784](https://github.com/expo/eas-cli/pull/2784) by [@kadikraman](https://github.com/kadikraman)) ### 🧹 Chores diff --git a/packages/eas-cli/src/worker/upload.ts b/packages/eas-cli/src/worker/upload.ts index 25e0f93312..63f41207a9 100644 --- a/packages/eas-cli/src/worker/upload.ts +++ b/packages/eas-cli/src/worker/upload.ts @@ -109,8 +109,10 @@ export async function uploadAsync(params: UploadParams): Promise { return retry(error); } - const body = await response.json().catch(() => null); - const errorMessage = body?.error ?? `Upload of "${filePath}" failed: ${response.statusText}`; + const getErrorMessageAsync = async (): Promise => { + const body = await response.json().catch(() => null); + return body?.error ?? `Upload of "${filePath}" failed: ${response.statusText}`; + }; if ( response.status === 408 || @@ -118,12 +120,12 @@ export async function uploadAsync(params: UploadParams): Promise { response.status === 429 || (response.status >= 500 && response.status <= 599) ) { - return retry(new Error(errorMessage)); + return retry(new Error(await getErrorMessageAsync())); } else if (response.status === 413) { const message = `Upload of "${filePath}" failed: File size exceeded the upload limit`; throw new Error(message); } else if (!response.ok) { - throw new Error(errorMessage); + throw new Error(await getErrorMessageAsync()); } return {