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

PDE-5774 fix(core): Catch HTTP 500 along with status codes >500 in RPC client #974

Merged
merged 3 commits into from
Feb 20, 2025

Conversation

rnegron
Copy link
Member

@rnegron rnegron commented Feb 18, 2025

We see Got id undefined but expected ID_NUMBER when calling RPC errors when it comes to RPC endpoints returning a 500 response. Inspecting the code, I believe we should likely catch the error before we check res.content.id.

After this change is released, we should update our log stream alarms to ALSO consider the Unable to reach the RPC server text instead of just the Got id ${res.content.id} but expected ${id} when calling RPC text. Both texts should be viable since we could have apps still running on previous versions.

@rnegron rnegron requested a review from a team as a code owner February 18, 2025 15:46
@rnegron
Copy link
Member Author

rnegron commented Feb 18, 2025

Ohh, 500 is a valid HTTP response for legacy reasons. I forgot!

@rnegron rnegron closed this Feb 18, 2025
@rnegron rnegron reopened this Feb 19, 2025
@rnegron rnegron changed the base branch from main to zapier-platform-major-release-17.0.0-dev February 19, 2025 21:00
@rnegron rnegron changed the base branch from zapier-platform-major-release-17.0.0-dev to main February 19, 2025 21:00
@rnegron rnegron changed the base branch from main to zapier-platform-major-release-17.0.0-dev February 19, 2025 21:01
@rnegron rnegron closed this Feb 19, 2025
@rnegron rnegron reopened this Feb 19, 2025
@rnegron
Copy link
Member Author

rnegron commented Feb 19, 2025

Following this PR, we should keep the retry logic for 5xx errors.

@@ -108,7 +108,7 @@ const createRpcClient = (event) => {
try {
res = await request(req);

if (res.status > 500) {
if (res.status >= 500) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HTTP 500 is now a non-standard response code (note this PR is targeting a major release branch as this could be a breaking change)

@@ -51,10 +51,10 @@ const mockRpcGetPresignedPostCall = (key) => {
});
};

const mockRpcFail = (error) => {
const mockRpcFail = (error, status = 400) => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HTTP 400 is the default error code for manual failures in the RPC API now, so I've set it as the default for this test

mocky.mockRpcFail('this is an expected explosion');
mocky.mockRpcFail('this is an expected explosion');
mocky.mockRpcFail('this is an expected explosion');
mocky.mockRpcFail('this is an expected explosion', 500);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The explode RPC method actually throws an HTTP 500 via an exception being raised 😅

Copy link
Contributor

@Natay Natay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙏

@rnegron rnegron merged commit 051bfff into zapier-platform-major-release-17.0.0-dev Feb 20, 2025
14 checks passed
@rnegron rnegron deleted the PDE-5774 branch February 20, 2025 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants