Skip to content

Commit

Permalink
chore: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
timsuchanek committed Jul 28, 2020
1 parent 512ceaa commit 3c3d777
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/packages/engine-core/src/NodeEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -858,14 +858,15 @@ ${this.lastErrorLog.fields.file}:${this.lastErrorLog.fields.line}:${this.lastErr
})

.catch(async (e) => {
const isError = await this.handleRequestError(e)
const isError = await this.handleRequestError(e, numTry < 3)
if (!isError) {
// retry
if (numTry < 3) {
await new Promise((r) => setTimeout(r, Math.random() * 1000))
return this.request(query, headers, numTry + 1)
}
}
throw isError
})
}

Expand Down Expand Up @@ -911,18 +912,23 @@ ${this.lastErrorLog.fields.file}:${this.lastErrorLog.fields.line}:${this.lastErr
}
})
.catch(async (e) => {
const isError = await this.handleRequestError(e)
const isError = await this.handleRequestError(e, numTry < 3)
if (!isError) {
// retry
if (numTry < 3) {
await new Promise((r) => setTimeout(r, Math.random() * 1000))
return this.requestBatch(queries, transaction, numTry + 1)
}
}

throw isError
})
}

private handleRequestError = async (error: Error & { code?: string }) => {
private handleRequestError = async (
error: Error & { code?: string },
graceful: boolean,
) => {
debug({ error })
let err
if (this.currentRequestPromise.isCanceled && this.lastError) {
Expand Down Expand Up @@ -1045,7 +1051,9 @@ Please look into the logs or turn on the env var DEBUG=* to debug the constantly
}),
)
debug(err.message)
return false
if (graceful) {
return false
}
}
}

Expand Down

0 comments on commit 3c3d777

Please sign in to comment.