Skip to content

Commit 75dd554

Browse files
committed
🔊 Improve http req timeout error
1 parent 3b1b464 commit 75dd554

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

packages/bot-engine/blocks/integrations/webhook/executeWebhookBlock.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
} from '@typebot.io/schemas'
1616
import { stringify } from 'qs'
1717
import { isDefined, isEmpty, isNotDefined, omit } from '@typebot.io/lib'
18-
import ky, { HTTPError, Options } from 'ky'
18+
import ky, { HTTPError, Options, TimeoutError } from 'ky'
1919
import { resumeWebhookExecution } from './resumeWebhookExecution'
2020
import { ExecuteIntegrationResponse } from '../../../types'
2121
import { parseVariables } from '@typebot.io/variables/parseVariables'
@@ -250,19 +250,18 @@ export const executeWebhook = async (
250250
})
251251
return { response, logs, startTimeShouldBeUpdated: true }
252252
}
253-
if (
254-
typeof error === 'object' &&
255-
error &&
256-
'code' in error &&
257-
error.code === 'ETIMEDOUT'
258-
) {
253+
if (error instanceof TimeoutError) {
259254
const response = {
260255
statusCode: 408,
261-
data: { message: `Request timed out.` },
256+
data: {
257+
message: `Request timed out. (${(request.timeout ?? 0) / 1000}ms)`,
258+
},
262259
}
263260
logs.push({
264261
status: 'error',
265-
description: `Webhook request timed out. (${request.timeout}ms)`,
262+
description: `Webhook request timed out. (${
263+
(request.timeout ?? 0) / 1000
264+
}s)`,
266265
details: {
267266
response,
268267
request,

0 commit comments

Comments
 (0)