(webhook) Add custom timeout option

Closes #1128
This commit is contained in:
Baptiste Arnaud
2024-01-04 08:08:00 +01:00
parent d247e02cad
commit 34917b00ef
9 changed files with 241 additions and 15 deletions

View File

@@ -32,9 +32,12 @@ import { VariableForTestInputs } from './VariableForTestInputs'
import { SwitchWithRelatedSettings } from '@/components/SwitchWithRelatedSettings'
import {
HttpMethod,
defaultTimeout,
defaultWebhookAttributes,
defaultWebhookBlockOptions,
maxTimeout,
} from '@typebot.io/schemas/features/blocks/integrations/webhook/constants'
import { NumberInput } from '@/components/inputs'
type Props = {
blockId: string
@@ -81,6 +84,9 @@ export const WebhookAdvancedConfigForm = ({
const updateIsCustomBody = (isCustomBody: boolean) =>
onOptionsChange({ ...options, isCustomBody })
const updateTimeout = (timeout: number | undefined) =>
onOptionsChange({ ...options, timeout })
const executeTestRequest = async () => {
if (!typebot) return
setIsTestResponseLoading(true)
@@ -196,6 +202,22 @@ export const WebhookAdvancedConfigForm = ({
)}
</AccordionPanel>
</AccordionItem>
<AccordionItem>
<AccordionButton justifyContent="space-between">
Advanced parameters
<AccordionIcon />
</AccordionButton>
<AccordionPanel pt="4">
<NumberInput
label="Timeout (s)"
defaultValue={options?.timeout ?? defaultTimeout}
min={1}
max={maxTimeout}
onValueChange={updateTimeout}
withVariableButton={false}
/>
</AccordionPanel>
</AccordionItem>
<AccordionItem>
<AccordionButton justifyContent="space-between">
Variable values for test

View File

@@ -0,0 +1,9 @@
import { NextApiRequest, NextApiResponse } from 'next'
export default async function handler(
req: NextApiRequest,
res: NextApiResponse
) {
await new Promise((resolve) => setTimeout(resolve, 11000))
res.status(200).json({ name: 'John Doe' })
}