feat(idempotency): implement IdempotencyHandler - #1416
Conversation
dreamorosi
left a comment
There was a problem hiding this comment.
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.
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.
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
IdempotencyHandlerwas 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.