2
0

🔊 Improve http req timeout error

This commit is contained in:
Baptiste Arnaud
2024-04-09 15:08:09 +02:00
parent 3b1b464890
commit 75dd554ac2

View File

@ -15,7 +15,7 @@ import {
} from '@typebot.io/schemas'
import { stringify } from 'qs'
import { isDefined, isEmpty, isNotDefined, omit } from '@typebot.io/lib'
import ky, { HTTPError, Options } from 'ky'
import ky, { HTTPError, Options, TimeoutError } from 'ky'
import { resumeWebhookExecution } from './resumeWebhookExecution'
import { ExecuteIntegrationResponse } from '../../../types'
import { parseVariables } from '@typebot.io/variables/parseVariables'
@ -250,19 +250,18 @@ export const executeWebhook = async (
})
return { response, logs, startTimeShouldBeUpdated: true }
}
if (
typeof error === 'object' &&
error &&
'code' in error &&
error.code === 'ETIMEDOUT'
) {
if (error instanceof TimeoutError) {
const response = {
statusCode: 408,
data: { message: `Request timed out.` },
data: {
message: `Request timed out. (${(request.timeout ?? 0) / 1000}ms)`,
},
}
logs.push({
status: 'error',
description: `Webhook request timed out. (${request.timeout}ms)`,
description: `Webhook request timed out. (${
(request.timeout ?? 0) / 1000
}s)`,
details: {
response,
request,