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 {
|
class JaxRequest {
|
||||||
constructor(config, endpoint, limiter) {
|
constructor(config, endpoint, limiter) {
|
||||||
this.config = config
|
this.config = config
|
||||||
this.endpoint = endpoint
|
this.endpoint = endpoint
|
||||||
this.limiter = limiter
|
this.limiter = limiter
|
||||||
this.retries = config.requestOptions.retriesBeforeAbort
|
this.retries = config.requestOptions.retriesBeforeAbort
|
||||||
|
|
||||||
|
this.sleep = promisify(setTimeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute() {
|
async execute() {
|
||||||
|
|
@ -26,10 +30,8 @@ class JaxRequest {
|
||||||
console.log('====================================')
|
console.log('====================================')
|
||||||
|
|
||||||
if (this.retries > 0) {
|
if (this.retries > 0) {
|
||||||
return setTimeout(
|
await this.sleep(this.config.requestOptions.delayBeforeRetry)
|
||||||
() => this.execute(),
|
return this.execute()
|
||||||
this.config.requestOptions.delayBeforeRetry,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue