Skip to content

πŸ› Express error handler captures errors with an empty message and no request contextΒ #4241

Closed

Description

@PierreBrisorgueil

What β€” server errors that reach the Express error handler with an empty message land in PostHog Error Tracking with nothing to read: no message, no stack, no route.
Why β€” such a group cannot be triaged: nobody can tell which request failed or whether a user saw it.

Scope

  • Seen in a downstream consumer: one Error Tracking group with an empty message, no stack, level unset, source system β€” 5 events in 30 days, 2 in the last day, first seen 3 weeks ago.
  • Level unset + source system match the 4-arg middleware in lib/services/errorTracker.js (setupExpressErrorHandler): it calls captureException(err, { distinctId, requestId }) only β€” no method, route or status. The Winston transport (logger.posthog.transport.js) always sets logLevel, so it is not the source.
  • Fix: add method, the route path (no query string), and the status code to the captured properties; when err.message is empty, capture a message like <METHOD> <route> <status> so the group is named; skip expected 4xx (status < 500), as the logger does for expected outcomes.
  • Tests: an error with an empty message passed to next() is captured with method, route and status; a 4xx is not captured.

Rank β€” P2: no user sees it, but the error is invisible to triage.

Filed by the gtm job
Created via /dev:issue

Activity

  1. PierreBrisorgueil commented on Oct 30, 2026

    @PierreBrisorgueil
    ContributorAuthor

    WIP β€” session 20261030T212813Z-E4C1707B, branch fix/error-tracker-request-context, started 2026-10-30T21:28:13Z

  2. PierreBrisorgueil commented on Oct 30, 2026

    @PierreBrisorgueil
    ContributorAuthor

    merged via drain (no hold, --review: false) β€” PR #4242, squash 3e3299f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions