NestJS Error Capture: Tracking HTTP Exceptions Through Filter and Interceptor Boundaries
For a production logistics agent, error tracking should use one failure envelope at every execution boundary, then attach cost and latency before the boundary reports or rethrows the failure. An HTTP exception filter alone cannot do that job: scheduled route refreshes and queue-driven shipment checks never enter the HTTP pipeline. The operational recommendation is to keep framework adapters thin,…
The article discusses the challenges of error tracking in NestJS, specifically in capturing HTTP exceptions, cron jobs, and queue workers. It recommends treating each execution boundary (HTTP requests, cron invocations, and queue deliveries) as separate entities feeding into the same internal recorder. The HTTP interceptor should establish timing and correlation context around controller execution, while the exception filter translates uncaught HTTP-path failures into a shared envelope and preserves the response contract.
A cron wrapper creates a fresh execution context, and a queue-worker wrapper starts from message metadata, records the current delivery attempt, and rethrows to allow the queue system to decide on retry or dead-lettering. The error tracking envelope should separate bounded dimensions from searchable detail, with fields such as boundary, operation, outcome, and low-cardinality error class being useful for SLO aggregation.
The article emphasizes the importance of preserving causal links between processes and avoiding assumptions about request-local state crossing asynchronous handoffs.
Brief written by urgent.news from Dev.to's own syndicated text. Machine-written — may contain errors; check the original before relying on it.