Fixing REST UI query error notification and adding better error for query timeout.
This commit is contained in:
parent
5396a8d8e0
commit
50f6dbebea
|
@ -136,7 +136,7 @@
|
||||||
notifications.success("Request sent successfully")
|
notifications.success("Request sent successfully")
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
notifications.error("Error running query")
|
notifications.error(`Query Error: ${error.message}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@ class Thread {
|
||||||
maxConcurrentWorkers: this.count,
|
maxConcurrentWorkers: this.count,
|
||||||
}
|
}
|
||||||
if (opts.timeoutMs) {
|
if (opts.timeoutMs) {
|
||||||
|
this.timeoutMs = opts.timeoutMs
|
||||||
workerOpts.maxCallTime = opts.timeoutMs
|
workerOpts.maxCallTime = opts.timeoutMs
|
||||||
}
|
}
|
||||||
this.workers = workerFarm(workerOpts, typeToFile(type))
|
this.workers = workerFarm(workerOpts, typeToFile(type))
|
||||||
|
@ -43,6 +44,7 @@ class Thread {
|
||||||
}
|
}
|
||||||
|
|
||||||
run(data) {
|
run(data) {
|
||||||
|
const timeoutMs = this.timeoutMs
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let fncToCall
|
let fncToCall
|
||||||
// if in test then don't use threading
|
// if in test then don't use threading
|
||||||
|
@ -52,7 +54,11 @@ class Thread {
|
||||||
fncToCall = this.workers
|
fncToCall = this.workers
|
||||||
}
|
}
|
||||||
fncToCall(data, (err, response) => {
|
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)
|
reject(err)
|
||||||
} else {
|
} else {
|
||||||
resolve(response)
|
resolve(response)
|
||||||
|
|
Loading…
Reference in New Issue