Comments (5)
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?
from fuels-ts.
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.
from fuels-ts.
Nope, not yet. This API looks good to me!
from fuels-ts.
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 .call()
but could still use @arboleya's solution to override the defaults they set in fuels.config.
{
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 options = {...theAbove...}
parameter in all of our program constructors. We could even provide all three ways of setting configurations:
- global via fuels.config.ts,
- program-specific via constructors / property setters,
- call-specific via @arboleya's proposal
from fuels-ts.
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 retryStrategyCallback
and onCallFail
are just examples of how easily extendable this config object would be. Functionality such as this would permit us to define sane defaults and also give the user the ability to override them if they choose to.
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.
from fuels-ts.
Related Issues (20)
- Support logs in `typegen`
- Add `messagesTypes` for the ABI
- Invalid Enum Data Size Error When Reading Storage With Option Struct
- Consolidate Wallet Transferring Documentation
- Use `V1` Encode Logic For `Upgrade` and `Upload` TXs
- feat: create a `DevTools` plugin for debugging browser related SDK issues HOT 1
- chore: Create configuration for debugging
- Merge `abi-coder` and `abi-typegen` packages
- Support `messagesTypes` for the ABI
- Consider removing `bech32` address format HOT 1
- Adding new `node` command to `fuels` CLI
- Issue with transaction execution error: Execution of the script associated with contract resulted in a non-zero exit code: 1. HOT 4
- Implement Transaction Queue Support HOT 2
- Proposal to Simplify `Provider.getTransactionCost`
- Support Generate Fake Resources Into `Account` Class
- Passing arguments to `create fuels` via NPM
- Integration/E2E tests for `Mint`, `Upgrade` and `Upload` transactions HOT 2
- Unpublish NPM versions
- Add `predicateData` Bytes To Predicate Resources And Inputs
- build: add CI job to automate labelling of PRs and issues
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fuels-ts.