From aab874e4e22471d5dc77e24aa9620df0a84f803a Mon Sep 17 00:00:00 2001 From: Kadi Kraman Date: Fri, 20 Dec 2024 15:03:52 +0000 Subject: [PATCH 1/3] Parse error only when needed --- packages/eas-cli/src/worker/upload.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/eas-cli/src/worker/upload.ts b/packages/eas-cli/src/worker/upload.ts index 25e0f93312..f8f690c423 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 getErrorMessage = async () => { + 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 getErrorMessage())); } 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 getErrorMessage()); } return { From 3c59c172e2f4ba3c9ba1b47746a24f2561bc5e2c Mon Sep 17 00:00:00 2001 From: Kadi Kraman Date: Fri, 20 Dec 2024 15:07:10 +0000 Subject: [PATCH 2/3] Add changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) 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 From 102475b24ef7dd945e298250b58ee1ab625703a2 Mon Sep 17 00:00:00 2001 From: Kadi Kraman Date: Fri, 20 Dec 2024 15:15:49 +0000 Subject: [PATCH 3/3] Fix linting --- packages/eas-cli/src/worker/upload.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/eas-cli/src/worker/upload.ts b/packages/eas-cli/src/worker/upload.ts index f8f690c423..63f41207a9 100644 --- a/packages/eas-cli/src/worker/upload.ts +++ b/packages/eas-cli/src/worker/upload.ts @@ -109,10 +109,10 @@ export async function uploadAsync(params: UploadParams): Promise { return retry(error); } - const getErrorMessage = async () => { + const getErrorMessageAsync = async (): Promise => { const body = await response.json().catch(() => null); return body?.error ?? `Upload of "${filePath}" failed: ${response.statusText}`; - } + }; if ( response.status === 408 || @@ -120,12 +120,12 @@ export async function uploadAsync(params: UploadParams): Promise { response.status === 429 || (response.status >= 500 && response.status <= 599) ) { - return retry(new Error(await getErrorMessage())); + 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(await getErrorMessage()); + throw new Error(await getErrorMessageAsync()); } return {