Skip to content

Commit

Permalink
🔊 Improve http req timeout error
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Apr 9, 2024
1 parent 3b1b464 commit 75dd554
Showing 1 changed file with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 75dd554

Please sign in to comment.