Skip to content

WebhookService has no timeout on outgoing HTTP requests #241

Description

@meshackyaro

Description

WebhookService.send() (src/webhook/webhook.service.ts) builds a raw http.request()/https.request() call with no timeout option set and no req.setTimeout(...) call. If a registered webhook endpoint accepts the TCP connection but never responds (or responds arbitrarily slowly), the request hangs indefinitely — sendWithRetry()'s per-attempt delay (1000 * (i + 1)) only kicks in after a request settles (resolves or rejects), so a single unresponsive endpoint can stall dispatch to that endpoint far longer than intended, and since dispatch() awaits Promise.allSettled across all endpoints, a slow endpoint delays the overall dispatch() call's resolution for every caller that awaits it (e.g. EscrowController.raiseDispute, every worker's sweep loop).

Component

Backend

Difficulty

🟢 Easy

Tasks

  • Add an explicit timeout to the http/https request in WebhookService.send() (e.g. req.setTimeout(ms, () => req.destroy(new Error('timeout'))))
  • Choose and document a sensible default timeout, ideally configurable via an env var
  • Add a test using a mock server that never responds, asserting the request fails after the configured timeout rather than hanging

Acceptance Criteria

  • An unresponsive webhook endpoint fails fast after a bounded timeout instead of hanging indefinitely
  • A test proves the timeout behavior

Estimated Time

2-4 hours

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions