-
-
Notifications
You must be signed in to change notification settings - Fork 450
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
Add retryExchange package #564
Conversation
💥 No ChangesetLatest commit: 64f17c8 Merging this PR will not cause any packages to be released. If these changes should not cause updates to packages in this repo, this is fine 🙂 If these changes should be published to npm, you need to add a changeset. Click here to learn what changesets are, and how to add one. Click here if you're a maintainer who wants to add a changeset to this PR |
…etried based on passed options
3c7996d
to
d3caa46
Compare
…mes before passing the successful result
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.
Nice work already, two minor comments
exchanges/retry/src/retryExchange.ts
Outdated
// Send failed responses to be retried by calling next on the retry$ subject | ||
tap(op => nextRetryOperation(op.operation)), | ||
// Only let through the first failed response | ||
filter(res => !res.operation.context.retryDelay) |
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.
I’m not 100% sure this is right; so we’re letting through the first error is what the comment says rather than the last retried error in case we run out of attempts?
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.
I agree with this, I can't see having the latest error being a problem.
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.
I think this should now be fixed
I just realised, we should probably check for |
"include": ["src"], | ||
"compilerOptions": { | ||
"baseUrl": "./", | ||
"paths": { |
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 is cool, but does our bundling process currently support aliasing?
I stopped using aliases after getting tired of writing alias maps in multiple places (tsconfig and webpack config)
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.
Everything seems fine as far as I can see - happy to swap them to be relative paths if preferred though
Looks siccc 🔥 |
Co-Authored-By: Andy Richardson <andy.john.richardson@gmail.com>
…into feat/retry-exchange
afbcfb0
to
e57a4e1
Compare
e57a4e1
to
2066f52
Compare
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 awesome, just two minor comments
Summary
Add a new retryExchange based on the previous implementation. This version adds some additional options.
It's an exchange factory of type
Options => Exchange
.Accepted options:
initialDelayMs
- the minimum delay between retries, defaults to 1000maxDelayMs
- the maximum delay that can be applied to an operationrandomDelay
- whether to apply a random delay to protect against thundering herd, defaults to truemaxNumberAttempts
- the maximum number of attempts to retry any given operation, defaults to InfinityretryIf
- optional function to apply to errors to determine whether they should be retriedPoints of note