Some quick fixes, making sure that automation queries respect timeout, they will timeout within the usual range.
This commit is contained in:
parent
43671f1aa3
commit
169fec29c6
|
@ -226,8 +226,19 @@ export function isClient(ctx: Ctx) {
|
||||||
return ctx.headers[Header.TYPE] === "client"
|
return ctx.headers[Header.TYPE] === "client"
|
||||||
}
|
}
|
||||||
|
|
||||||
export function timeout(timeMs: number) {
|
export function timeout(
|
||||||
return new Promise(resolve => setTimeout(resolve, timeMs))
|
timeMs: number,
|
||||||
|
opts?: { reject?: boolean }
|
||||||
|
): Promise<void> {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
setTimeout(() => {
|
||||||
|
if (opts?.reject) {
|
||||||
|
reject(new Error(`timed out - ${timeMs}ms`))
|
||||||
|
} else {
|
||||||
|
resolve()
|
||||||
|
}
|
||||||
|
}, timeMs)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isAudited(event: Event) {
|
export function isAudited(event: Event) {
|
||||||
|
|
|
@ -159,7 +159,7 @@
|
||||||
newQuery.fields.queryString = queryString
|
newQuery.fields.queryString = queryString
|
||||||
newQuery.fields.authConfigId = authConfigId
|
newQuery.fields.authConfigId = authConfigId
|
||||||
newQuery.fields.disabledHeaders = restUtils.flipHeaderState(enabledHeaders)
|
newQuery.fields.disabledHeaders = restUtils.flipHeaderState(enabledHeaders)
|
||||||
newQuery.schema = schema
|
newQuery.schema = schema || {}
|
||||||
|
|
||||||
return newQuery
|
return newQuery
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ const PATH_PREFIX = "/bulladmin"
|
||||||
|
|
||||||
export async function init() {
|
export async function init() {
|
||||||
// Set up queues for bull board admin
|
// Set up queues for bull board admin
|
||||||
const backupQueue = await backups.getBackupQueue()
|
const backupQueue = backups.getBackupQueue()
|
||||||
const queues = [automationQueue]
|
const queues = [automationQueue]
|
||||||
if (backupQueue) {
|
if (backupQueue) {
|
||||||
queues.push(backupQueue)
|
queues.push(backupQueue)
|
||||||
|
|
|
@ -10,6 +10,8 @@ import {
|
||||||
AutomationStepSchema,
|
AutomationStepSchema,
|
||||||
AutomationStepType,
|
AutomationStepType,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
|
import { utils } from "@budibase/backend-core"
|
||||||
|
import env from "../../environment"
|
||||||
|
|
||||||
export const definition: AutomationStepSchema = {
|
export const definition: AutomationStepSchema = {
|
||||||
name: "External Data Connector",
|
name: "External Data Connector",
|
||||||
|
@ -84,7 +86,10 @@ export async function run({ inputs, appId, emitter }: AutomationStepInput) {
|
||||||
})
|
})
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await queryController.executeV2(ctx, { isAutomation: true })
|
await Promise.race([
|
||||||
|
queryController.executeV2(ctx, { isAutomation: true }),
|
||||||
|
utils.timeout(env.QUERY_THREAD_TIMEOUT, { reject: true }),
|
||||||
|
])
|
||||||
const { data, ...rest } = ctx.body
|
const { data, ...rest } = ctx.body
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in New Issue