OUT-3680: read webhook body before sleep to avoid ECONNRESET#101
OUT-3680: read webhook body before sleep to avoid ECONNRESET#101SandipBajracharya merged 2 commits intomainfrom
Conversation
The Assembly and Dropbox webhook handlers slept 800ms, authenticated, and queried the DB before consuming the request body. With the upstream tunnel holding the socket open, the body stream was getting aborted (ECONNRESET) by the time `req.json()` ran. Read the body first, then sleep and process. Also tighten Assembly webhook validation: switch to `webhookEvent.data.object` (authoritative source from Copilot) and drop the unused top-level `object` field on `AssemblyWebhookSchema`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis PR fixes ECONNRESET errors in both Assembly and Dropbox webhook handlers by consuming the request body ( Confidence Score: 4/5Safe to merge; only a P2 style finding present. The body-before-sleep fix is sound for both handlers, the parseWebhook refactor is clean, and the || → && logic change correctly tightens validation. One P2 note about a redundant middle operand in the && chain that widens the TypeScript inferred type, but no correctness issues. src/features/webhook/assembly/lib/webhook.service.ts — redundant truthiness check in validateHandleableEvent widens inferred type. Important Files Changed
Sequence DiagramsequenceDiagram
participant C as Client
participant AW as Assembly Webhook
participant DW as Dropbox Webhook
participant WS as WebhookService
Note over C,WS: Assembly flow after fix
C->>AW: POST request
AW->>AW: consume body first
AW->>AW: sleep 800ms
AW->>AW: authenticate user
AW->>WS: parseWebhook(parsedBody)
WS-->>AW: webhookEvent
AW->>WS: validateHandleableEvent
WS-->>AW: eventType or null
AW-->>C: 200 OK
Note over C,DW: Dropbox flow after fix
C->>DW: POST request
DW->>DW: check signature header
DW->>DW: consume body first
DW->>DW: sleep 800ms
DW->>DW: verify HMAC
DW-->>C: 200 OK
Reviews (1): Last reviewed commit: "fix(OUT-3680): read webhook body before ..." | Re-trigger Greptile |
Summary
req.json(). Over a tunnel (ngrok / upstream LB) the request body stream was being aborted by the time we tried to parse it, surfacing asError: aborted { code: 'ECONNRESET' }right after theAuthorizing with key:log from the Copilot SDK.parseWebhooknow takes the parsed body instead of theNextRequest.webhookEvent.data.object(the authoritative field from Copilot) and dropped the unused top-levelobjectfromAssemblyWebhookSchema.Test plan
file.createdwebhook and confirm no ECONNRESET; sync still flows through to Dropboxfile.updatedandfile.deletedwebhooklink-type Assembly objects are still skipped viadata.objectcheck🤖 Generated with Claude Code