🔊 Improve http req timeout error
This commit is contained in:
@@ -15,7 +15,7 @@ import {
|
|||||||
} from '@typebot.io/schemas'
|
} from '@typebot.io/schemas'
|
||||||
import { stringify } from 'qs'
|
import { stringify } from 'qs'
|
||||||
import { isDefined, isEmpty, isNotDefined, omit } from '@typebot.io/lib'
|
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 { resumeWebhookExecution } from './resumeWebhookExecution'
|
||||||
import { ExecuteIntegrationResponse } from '../../../types'
|
import { ExecuteIntegrationResponse } from '../../../types'
|
||||||
import { parseVariables } from '@typebot.io/variables/parseVariables'
|
import { parseVariables } from '@typebot.io/variables/parseVariables'
|
||||||
@@ -250,19 +250,18 @@ export const executeWebhook = async (
|
|||||||
})
|
})
|
||||||
return { response, logs, startTimeShouldBeUpdated: true }
|
return { response, logs, startTimeShouldBeUpdated: true }
|
||||||
}
|
}
|
||||||
if (
|
if (error instanceof TimeoutError) {
|
||||||
typeof error === 'object' &&
|
|
||||||
error &&
|
|
||||||
'code' in error &&
|
|
||||||
error.code === 'ETIMEDOUT'
|
|
||||||
) {
|
|
||||||
const response = {
|
const response = {
|
||||||
statusCode: 408,
|
statusCode: 408,
|
||||||
data: { message: `Request timed out.` },
|
data: {
|
||||||
|
message: `Request timed out. (${(request.timeout ?? 0) / 1000}ms)`,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
logs.push({
|
logs.push({
|
||||||
status: 'error',
|
status: 'error',
|
||||||
description: `Webhook request timed out. (${request.timeout}ms)`,
|
description: `Webhook request timed out. (${
|
||||||
|
(request.timeout ?? 0) / 1000
|
||||||
|
}s)`,
|
||||||
details: {
|
details: {
|
||||||
response,
|
response,
|
||||||
request,
|
request,
|
||||||
|
|||||||
Reference in New Issue
Block a user