-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Retry mechanism #1078
Comments
Great idea; transient failures should indeed be accounted for. We could have a simple option like this (below) and have an internal retry pattern strategy with exponential back-off. // if nothing is specified, we could have a default maxRetries=5
contract.functions.xyz(params).call({ maxRetries: 5 }); @digorithm Is there something like this on the Rust SDK already? |
Nope, not yet. This API looks good to me! |
What about a global fuels.config.ts file in addition to @arboleya's proposal? The user then wouldn't have to set it on every {
maxRetries: 5,
txParams: {
gasPrice: 2
},
contracts: {
maxRetries: 2,
txParams: {
gasPrice: 1
}
}
} Or if we don't go down this route, we could put an optional
|
That's a lot of complexity for very little gain. The JS ecosystem already suffers from way too many config files, I'd rather not contribute to that, haha. And by very little gain I mean: gas price and many other transaction related configurations are mostly configured per call, usually being dynamically changed very quickly; often gas price being queried from external sources before a call happens. It isn't something that's set one time and the user rarely touches it. Retries does fit in this behaviour, though. But adding a whole new config file for just this value isn't justifiable. |
Haha, yeah, makes sense. However, having to specify retries on a per-call basis might be cumbersome. A per-program config object passed via the constructor would alleviate some of that pain, so I think it's worth considering. const myContract = new Contract(theAbi, ...whateverElse...,
{
maxRetries: 5,
retryStrategyCallback: (retryNumber, isLastRetry) => ({callAgain: true}),
onCallFail: async () => await notifyTheWhiteHouse()
}) The It could also be modified like below, although I'm not a fan because it's one more way for bugs to creep up: myContract.configs.maxRetries = -1; // if negative, retry to infinity, etc. |
We should support an optional, configurable parameter to enable retries when sending a transaction to the node. This mechanism's design and API are part of this work; nothing in mind yet!
The text was updated successfully, but these errors were encountered: