Skip to content

MEDIUM: fireWebhook awaited synchronously in session-scoring — sequential endpoint timeouts stall scoring job #97

Description

@walidboulanouar

Problem

packages/jobs/src/session-scoring.ts line 139: await fireWebhook(...) is called synchronously. Internally deliverToEndpoint iterates endpoints in a for-loop with up to 10s timeout each. An org with N slow/timing-out webhook endpoints holds the scoring job open for up to N × 10s.

With Trigger.dev retry backoff < webhook timeout, retries pile up before the first completes.

Fix

Option A — run deliveries concurrently:

await Promise.all(endpoints.map(ep => deliverToEndpoint(ep, ...)));

Option B — move fireWebhook to a fire-and-forget child task:

await webhookDeliveryTask.trigger({ orgId, event, data });
// returns immediately; scoring is not blocked on delivery

Option B is preferred as it completely decouples scoring latency from delivery infrastructure.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions