Some quick fixes, making sure that automation queries respect timeout, they will timeout within the usual range.

This commit is contained in:
mike12345567 2024-02-13 18:21:41 +00:00
parent 43671f1aa3
commit 169fec29c6
4 changed files with 21 additions and 5 deletions

View File

@ -226,8 +226,19 @@ export function isClient(ctx: Ctx) {
return ctx.headers[Header.TYPE] === "client"
}
export function timeout(timeMs: number) {
return new Promise(resolve => setTimeout(resolve, timeMs))
export function timeout(
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) {

View File

@ -159,7 +159,7 @@
newQuery.fields.queryString = queryString
newQuery.fields.authConfigId = authConfigId
newQuery.fields.disabledHeaders = restUtils.flipHeaderState(enabledHeaders)
newQuery.schema = schema
newQuery.schema = schema || {}
return newQuery
}

View File

@ -15,7 +15,7 @@ const PATH_PREFIX = "/bulladmin"
export async function init() {
// Set up queues for bull board admin
const backupQueue = await backups.getBackupQueue()
const backupQueue = backups.getBackupQueue()
const queues = [automationQueue]
if (backupQueue) {
queues.push(backupQueue)

View File

@ -10,6 +10,8 @@ import {
AutomationStepSchema,
AutomationStepType,
} from "@budibase/types"
import { utils } from "@budibase/backend-core"
import env from "../../environment"
export const definition: AutomationStepSchema = {
name: "External Data Connector",
@ -84,7 +86,10 @@ export async function run({ inputs, appId, emitter }: AutomationStepInput) {
})
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
return {