1
0
Fork 0
mirror of synced 2024-09-10 14:35:47 +12:00

Fixing REST UI query error notification and adding better error for query timeout.

This commit is contained in:
mike12345567 2022-04-14 17:28:14 +01:00
parent 5180603374
commit 80a41235dd
2 changed files with 8 additions and 2 deletions

View file

@ -136,7 +136,7 @@
notifications.success("Request sent successfully")
}
} catch (error) {
notifications.error("Error running query")
notifications.error(`Query Error: ${error.message}`)
}
}

View file

@ -36,6 +36,7 @@ class Thread {
maxConcurrentWorkers: this.count,
}
if (opts.timeoutMs) {
this.timeoutMs = opts.timeoutMs
workerOpts.maxCallTime = opts.timeoutMs
}
this.workers = workerFarm(workerOpts, typeToFile(type))
@ -43,6 +44,7 @@ class Thread {
}
run(data) {
const timeoutMs = this.timeoutMs
return new Promise((resolve, reject) => {
let fncToCall
// if in test then don't use threading
@ -52,7 +54,11 @@ class Thread {
fncToCall = this.workers
}
fncToCall(data, (err, response) => {
if (err) {
if (err && err.type === "TimeoutError") {
reject(
new Error(`Query response time exceeded ${timeoutMs}ms timeout.`)
)
} else if (err) {
reject(err)
} else {
resolve(response)