Skip to content

Commit 0f99b4e

Browse files
icecrasher321claude
andcommitted
improvement(webhooks): overlap the webhook path lookup with body parsing
findAllWebhooksForPath depends only on the request path, so the ingest route starts it before reading the body stream and awaits it after the challenge short-circuit — one round trip off the pre-ack path. A challenge response abandons a read-only query. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 01ed7cc commit 0f99b4e

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

  • apps/sim/app/api/webhooks/trigger/[path]

apps/sim/app/api/webhooks/trigger/[path]/route.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,13 @@ async function handleWebhookDelivery(
141141
? Number(slackRequestTimestamp) * 1000
142142
: undefined
143143

144+
/**
145+
* Depends only on the path, so the read-only lookup overlaps the body stream
146+
* read below; a challenge short-circuit simply abandons the result.
147+
*/
148+
const webhookLookupPromise = findAllWebhooksForPath({ requestId, path })
149+
webhookLookupPromise.catch(() => {})
150+
144151
const parseResult = await parseWebhookBody(request, requestId)
145152

146153
// Check if parseWebhookBody returned an error response
@@ -159,8 +166,8 @@ async function handleWebhookDelivery(
159166
return challengeResponse
160167
}
161168

162-
// Find all webhooks for this path (multiple webhooks in one workflow may share a path)
163-
const allWebhooksForPath = await findAllWebhooksForPath({ requestId, path })
169+
// Multiple webhooks in one workflow may share a path
170+
const allWebhooksForPath = await webhookLookupPromise
164171

165172
const pathWebhooks = allWebhooksForPath.filter(({ webhook: foundWebhook }) =>
166173
acceptsPathWebhookDelivery(foundWebhook.provider)

0 commit comments

Comments
 (0)