vcfvct / typescript-retry-decorator Goto Github PK
View Code? Open in Web Editor NEWlightweight typescript retry decorator with 0 dependency.
License: MIT License
lightweight typescript retry decorator with 0 dependency.
License: MIT License
It would be helpful to have the ability to handle what gets thrown in the end, in case there is a need to remap the error to something else. I did not see this functionality in the documentation, but perhaps it is already possible?
And thanks for making this library!
Hello, how does this plugin handle the last exception? For example, I set to retry 3 times. After 3 times, a 503 exception still occurs, and an email is sent. But after the plugin retries 3 times, I can't catch the exception, and I can't send the email. How to deal with this scenario?
For certain scenarios like those described in this AWS blog post, including jitter in the exponential backoff calculation can be hugely beneficial. Would be great if there was a simple option to enable exponential backoff with jitter in the decorator.
Hi there! Seems like a nice and useful library but, unfortunately, I'm getting the following type error:
I played with different TSconfig & package.json setups, tweaking this and that, but still can't even say if it's a deterministic issue or something specific to my IDE. Sometimes it appears and sometimes โ not.
The above screenshot uses $ tsc --init
> tsconfig.json
version ๐ค Nothing fancy.
I realize it's hard to help me without a reproduceable code.
My hope is that this error might look familiar to the authors. Otherwise I'll try to find time to come up with a better demo.
I need to pass custom defined error classes on the value
field of the RetryOptions
options object:
import { Retryable, BackOffPolicy} from "typescript-retry-decorator"
class CustomError extends Error {
constructor(message?: string | undefined) {
super(message)
Object.setPrototypeOf(this, CustomError.prototype)
this.name = 'CustomError'
}
}
class Test {
@Retryable({
maxAttempts: 3,
backOffPolicy: BackOffPolicy.FixedBackOffPolicy,
backOff: 1000,
value: [CustomError],
})
public async test() {
throw new CustomError()
}
}
Type 'typeof CustomError' is not assignable to type 'ErrorConstructor'.
Type 'typeof CustomError' provides no match for the signature '(message?: string | undefined): Error'
My build target is esnext
Could someone provide an example where a custom error class is passed to the value
field of the RetryOptions
object? The tests and examples do not include such case
A common use case is to retry errors of certain types like FetchError
or similar. doRetry
does the job, but it is inconvenient for such a common use case.
Is it possible to add an option like errors: ErrorConstructor[] | ErrorConstructor
to specify which error classes need to be retried?
Would be fantastic to include the original exception message that caused the final retry
Currently we see
Error: Failed for 'foo' for 2 times.
Would like to see
Error: Failed for 'fo' for 2 times . Orginal Error : 'Null PTR Exception'
I know the original error message is included when retries are exhausted, but it would be great to have the option to bubble up the original error instance itself stack trace and all. This would, of course, not be expected to be enabled by default as it would be a breaking change to existing functionality, but I imagine it could be enabled via the options.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.