-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
fix(@aws-amplify/datastore): Retry mutation if GraphQL timeout due to bad network condition. #6542
fix(@aws-amplify/datastore): Retry mutation if GraphQL timeout due to bad network condition. #6542
Conversation
Codecov Report
@@ Coverage Diff @@
## main #6542 +/- ##
==========================================
+ Coverage 74.80% 75.38% +0.58%
==========================================
Files 215 215
Lines 13522 13524 +2
Branches 2661 2663 +2
==========================================
+ Hits 10115 10195 +80
+ Misses 3208 3127 -81
- Partials 199 202 +3
Continue to review full report at Codecov.
|
|
||
if ( | ||
error.message === 'Network Error' || | ||
error.message === 'timeout of 0ms exceeded' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks related to our underlying axios
implementation:
@manueliglesias Is this a resilient enough message to key off of?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch @ericclemmons, I don't think it would be resilient enough, I think it would be better to include additional keys in the GraphQL error if needed on GraphQLAPI.ts
(e.g. an error code with values like the ECONNABORTED
mentioned in the linked issue, or similar)
errors: [new GraphQLError(err.message)], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey thanks for the review! Would you guys do the honor to make the changes so they would work gracefully.
I'll be happy to test it out on my end!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May I know how can I pass the errorCode into GraphQLError
interface?
I was thinking of passing the original error, is that ideal?
response = {
data: {},
errors: [new GraphQLError(err.message, null, null, null, null, err)],
};
I was able to successfully test the PR in iOS simulator
Since it's not possible to simulate 100% Packet Loss (or other network conditions) in Detox (the e2e testing framework we use for RN apps) we won't be able to add an e2e test for this fix but we should be able to at least add a unit test that captures this. I will work on adding the test today and will merge the PR afterward. Thank you so much for this contribution, @nubpro! |
4f865a4
to
c560cd2
Compare
Unit test has been added: https://github.com/aws-amplify/amplify-js/pull/6542/files#diff-b21a0f0d7db920e7ce7ad487d762f40fc3aca6b288e621a8db17347f50a480db Going to ask @amhinson to give the test a once-over and then we'll merge this PR today. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving. See #6542 (comment) for more detail
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
This pull request has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs. Looking for a help forum? We recommend joining the Amplify Community Discord server |
Issue #, if available:
I didn't open a new issue, but you can reproduce the problem as follow:
The consequences of not handling this error is that DataStore will dequeue this mutation and the record will never be updated to the server which is a big nono.
Description of changes:
This PR will make sure mutation processor to perform retry if the mutation GraphQL returns
timeout of 0ms exceeded
.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.