-
Notifications
You must be signed in to change notification settings - Fork 146
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
feat(idempotency): implement IdempotencyHandler #1416
feat(idempotency): implement IdempotencyHandler #1416
Conversation
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.
Looking good, I just would like to address one return type and remove a ts-ignore
before merging
* In most cases we can retry successfully on this exception. | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore |
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.
Before we merge, can we fix this return type and remove the comment?
Based on what I see, we either need to change the return type to Promise<U | undefined>
or make sure that the function returns something in the catch
block when the if
statement is skipped.
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.
Hmm this is weird construct we have there. Adding undefined
to the Promise would leak it further to makeIdempotentFunction
and also higher to the user api, which I'd like to avoid. TS complains about missing return statement outside of the for-loop. But adding a statement makes it impossible to test, because this return statement is unreachable. I have added a throw with coverage ignore.
This is a small PR for the #1303 implementation. Most of the
IdempotencyHandler
was already implemented and aligned with decorator and function wrapper. In addition, I have added a try mechanism to mitigate rare race conditions error, similar to python implementation.Description of your changes
How to verify this change
Related issues, RFCs
Issue number: closes #1303
Checklist
Breaking change checklist
Is it a breaking change?: NO
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.