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

Revert error should not be retried #254

Merged
merged 11 commits into from
Oct 23, 2023
Merged

Revert error should not be retried #254

merged 11 commits into from
Oct 23, 2023

Conversation

jpuri
Copy link
Contributor

@jpuri jpuri commented Oct 12, 2023

Fixes: https://github.com/MetaMask/MetaMask-planning/issues/1461

This is an issue brought up by blockaid team, in case of revert we should not retry and send back original error.

Copy link
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

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

This change makes sense. I also checked the other middleware to make sure there wasn't any other place we needed to do this. The fetch middleware also retries requests, but has an allowlist of retriable errors, and this revert error isn't one of them, so we're good on that (these retriable errors, by the way, are what I think the issue you found is referring to).

Also — and this is just a sidebar — I don't really know why retryOnEmpty retries errors; based on its name it should only retry empty requests. Unfortunately I don't have enough context on this to know what the right thing to do here is, so it's probably best to leave it alone.

In conclusion, your change makes sense, I just had some tweaks.

src/retryOnEmpty.ts Outdated Show resolved Hide resolved
@jpuri
Copy link
Contributor Author

jpuri commented Oct 16, 2023

Hey @mcmire : I updated the PR and also added unit test coverage.

@jpuri jpuri marked this pull request as ready for review October 16, 2023 14:13
@jpuri jpuri requested a review from a team as a code owner October 16, 2023 14:13
@jpuri jpuri requested a review from mcmire October 16, 2023 14:13
Copy link
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

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

Just a few suggestions. Solution looks good aside from this though!

src/retryOnEmpty.test.ts Outdated Show resolved Hide resolved
src/retryOnEmpty.ts Outdated Show resolved Hide resolved
test/util/helpers.ts Outdated Show resolved Hide resolved
src/utils/error.test.ts Outdated Show resolved Hide resolved
jpuri and others added 4 commits October 17, 2023 13:54
Co-authored-by: Elliot Winkler <elliot.winkler@gmail.com>
Co-authored-by: Elliot Winkler <elliot.winkler@gmail.com>
Co-authored-by: Elliot Winkler <elliot.winkler@gmail.com>
@jpuri jpuri requested a review from mcmire October 17, 2023 09:58
@jpuri
Copy link
Contributor Author

jpuri commented Oct 17, 2023

Hey @mcmire : thanks a lot for review feedbacks, I addressed all of those.

test/util/helpers.ts Outdated Show resolved Hide resolved
@jpuri jpuri requested a review from mcmire October 20, 2023 08:51
Copy link
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

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

Looks good!

@jpuri jpuri merged commit 0cbbfd6 into main Oct 23, 2023
16 checks passed
@jpuri jpuri deleted the revert_fix branch October 23, 2023 06:05
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