Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[eas-cli] parse request body for error only when needed #2784

Merged
merged 3 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 6 additions & 4 deletions packages/eas-cli/src/worker/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,21 +109,23 @@
return retry(error);
}

const body = await response.json().catch(() => null);
const errorMessage = body?.error ?? `Upload of "${filePath}" failed: ${response.statusText}`;
const getErrorMessage = async () => {

Check failure on line 112 in packages/eas-cli/src/worker/upload.ts

View workflow job for this annotation

GitHub Actions / Test with Node 22

Names should end with 'Async' for async functions. Rename 'getErrorMessage' to 'getErrorMessageAsync'

Check warning on line 112 in packages/eas-cli/src/worker/upload.ts

View workflow job for this annotation

GitHub Actions / Test with Node 22

Missing return type on function
const body = await response.json().catch(() => null);
return body?.error ?? `Upload of "${filePath}" failed: ${response.statusText}`;
}

Check warning on line 115 in packages/eas-cli/src/worker/upload.ts

View workflow job for this annotation

GitHub Actions / Test with Node 22

Insert `;`

if (
response.status === 408 ||
response.status === 409 ||
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 {
Expand Down
Loading