mirror of
https://github.com/langgenius/dify.git
synced 2026-11-10 21:35:45 +08:00
Co-authored-by: QuantumGhost <obelisk.reg+git@gmail.com> Co-authored-by: yyh <yuanyouhuilyz@gmail.com>
22 lines
698 B
TypeScript
22 lines
698 B
TypeScript
export class HumanInputSubmissionPreparationError extends Error {
|
|
constructor() {
|
|
super('Human Input submission could not establish the workflow connection')
|
|
this.name = 'HumanInputSubmissionPreparationError'
|
|
}
|
|
}
|
|
|
|
export const prepareHumanInputFormSubmission = async (prepare: () => Promise<boolean>) => {
|
|
let timer: ReturnType<typeof setTimeout> | undefined
|
|
try {
|
|
const ready = await Promise.race([
|
|
prepare(),
|
|
new Promise<never>((_, reject) => {
|
|
timer = setTimeout(() => reject(new HumanInputSubmissionPreparationError()), 15_000)
|
|
}),
|
|
])
|
|
if (!ready) throw new HumanInputSubmissionPreparationError()
|
|
} finally {
|
|
clearTimeout(timer)
|
|
}
|
|
}
|