mirror of
https://github.com/vkaelin/LeagueStats.git
synced 2026-03-25 12:57:28 +00:00
fix: recursion of JaxRequest now works if we receive 500/503
This commit is contained in:
parent
668930d7ca
commit
d698057fae
1 changed files with 6 additions and 4 deletions
|
|
@ -1,9 +1,13 @@
|
|||
const { promisify } = require('util')
|
||||
|
||||
class JaxRequest {
|
||||
constructor(config, endpoint, limiter) {
|
||||
this.config = config
|
||||
this.endpoint = endpoint
|
||||
this.limiter = limiter
|
||||
this.retries = config.requestOptions.retriesBeforeAbort
|
||||
|
||||
this.sleep = promisify(setTimeout)
|
||||
}
|
||||
|
||||
async execute() {
|
||||
|
|
@ -26,10 +30,8 @@ class JaxRequest {
|
|||
console.log('====================================')
|
||||
|
||||
if (this.retries > 0) {
|
||||
return setTimeout(
|
||||
() => this.execute(),
|
||||
this.config.requestOptions.delayBeforeRetry,
|
||||
)
|
||||
await this.sleep(this.config.requestOptions.delayBeforeRetry)
|
||||
return this.execute()
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue