Skip to content

TT-035: NestJS unhandled controller exceptions (500 from Nest's exception filter) are never reported; docs say global process handlers cover uncaught failures #920

Closed

Description

@unjica

TT ID: TT-035 · Severity: P2 · Area: SDK / Docs (NestJS) · Found by: QA (weekly deep test, other integrations) · Production: API v1.22.25 · SDK: @telemetry-tracker/node 1.4.2 / core 1.5.3 (npm) · NestJS 12.3.2

Summary

The NestJS guide says "Global process handlers cover uncaught failures." Unhandled exceptions thrown in controllers/services during a request never reach uncaughtException/unhandledRejection. Nest's built-in BaseExceptionFilter catches them, logs them, and returns 500 Internal server error. So the most common backend failure in a Nest app (a route that throws) is never reported unless the developer adds trackError() by hand.

Steps to reproduce

  1. nest new my-nest-api (Nest 12), npm i @telemetry-tracker/node. Follow /docs/nestjs exactly: init() in main.ts before NestFactory.create, plus the TelemetryMiddleware with forRoutes("*").
  2. Add routes: GET /boom → throw new Error("boom"); GET /boom-async → async handler that throws after await.
  3. Call each route. Both return HTTP 500, and the Nest logger prints ERROR [ExceptionsHandler] ....
  4. Check Issues / GET /api/errors?range=24h.

Expected

Route exceptions that end in a 500 are reported (or the docs state clearly that they aren't and show the filter to add).

Actual

  • 0 errors reported for /boom and /boom-async across 4 runs (r1, r2, crash1, crash2). No /ingest/error request is sent.
  • Controls in the same app are reported: the docs "Handled errors" trackError() example (1 per run), a real unhandledRejection from a detached promise, and an uncaughtException from a setTimeout throw. The last two are reported, and then the process exits.

Suggested fix

Ship or document a global exception filter, e.g.

@Catch()
export class TelemetryExceptionFilter extends BaseExceptionFilter {
  catch(exception: unknown, host: ArgumentsHost) {
    const status = exception instanceof HttpException ? exception.getStatus() : 500;
    if (status >= 500) trackError(exception as Error, { source: "nest.exceptionFilter" });
    super.catch(exception, host);
  }
}
// main.ts: app.useGlobalFilters(new TelemetryExceptionFilter(app.get(HttpAdapterHost).httpAdapter));

and reword "Global process handlers cover uncaught failures" to say they cover only failures outside Nest's request pipeline.

Notes

  • Not security-sensitive.
  • Evidence (QA only): QA project app qa-sweep, environment qa-deep-nest, releases deep-nest-2026-11-04-*, 2026-11-04.

Activity

  1. added
    bug
    sdk
    qa
    on Nov 4, 2026
  2. added a commit that references this issue on Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugqasdk

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions