-
-
Notifications
You must be signed in to change notification settings - Fork 596
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
Support Idempotency #1210
Support Idempotency #1210
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1210 +/- ##
==========================================
+ Coverage 92.34% 92.36% +0.01%
==========================================
Files 54 54
Lines 5294 5307 +13
Branches 1191 1195 +4
==========================================
+ Hits 4889 4902 +13
Misses 405 405
Continue to review full report at Codecov.
|
@mtrezza How does this look? Is this an accurate way to test idempotency? |
Wow, I had this on my list for next month but you overtook me there 👏 |
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.
Looks good, just some minor comments.
Does the JS SDK have an automated request retry mechanism like the iOS and Android SDKs? If so, I think a test case makes sense that ensures that the UUID does not change on request retry. That may then also require additional logic in the REST controller to ensure that the UUID does not change.
It could make sense to also add test cases for jobs and object save and update, then we would cover the whole range of functionality, but I think initially a test case just for the Parse Cloud function does suffice as well.
I've looked into the Parse JS SDK and it seems that it does not have an auto-retry mechanism on failed requests, nor does XHR. For future reference: If such a mechanism ever gets implemented, similar to how it exists in the iOS and Android SDKs, this test case will likely need to be adapted to properly test that the UUID does not change. |
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.
Can we add a test where we ensure that the request ID header is not sent for GET request?
@mtrezza I've added additional test. There is an auto-retry strategy in the SDK (in RESTController.js) I added a fix for that also. This is ready for review |
Great, I will take a look later today. |
@mtrezza @davimacedo How does this look? |
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 job @dplewis. It looks good to me.
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.
It's already merged but I reviewed it anyway just to be sure and it looks good. Thanks for this PR!
@mtrezza I didn’t want to open a new issue, I’m writing documentation for this. How would you catch a duplicate request error?
|
@dplewis Yes, in addition the catch block would check for The comment is not correct in all cases, it could "run for the first time" but end up in the catch block for another reason than duplicate request. So you could add "runs for first time and succeeds" in try block and in the catch block "runs for first times and failed" if error code is not 159, and "runs multiple times as duplicate requests" if error code is 159. |
Can you think of a way to replicate a duplicate request in a test environment?
Edit: I can just create a custom RESTController |
Sure, just send an identical request ID in the header and the request should fail as duplicate request. To send an identical request ID you could |
The tests cases are good, I was referring to a real environment. Website, press a button and send a duplicate request. |
|
Ref: parse-community/parse-server#6744, parse-community/parse-server#6748
Idempotency enforcement for client requests. This deduplicates requests where the client intends to send one request to Parse Server but due to network issues the server receives the request multiple times.
Caution, this is an experimental feature that may not be appropriate for production.
To enable use either of the following:
Parse.CoreManager.set('IDEMPOTENCY': true)
Parse.idempotency = true
;This PR addresses
X-Parse-Request-Id
uuid to the request.