-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Self-hosted/on-premise
Which SDK are you using?
@sentry/nestjs
SDK Version
9.4.0
Framework Version
NestJS 11.1.3
Link to Sentry event
No event is created — that's the bug.
SDK Setup
// sentry-instrument.ts (loaded before everything else)
import * as Sentry from '@sentry/nestjs';
Sentry.init({
dsn: '...',
environment: 'test',
});// app.module.ts
import { SentryGlobalFilter, SentryModule } from '@sentry/nestjs/setup';
@Module({
imports: [SentryModule.forRoot(), /* ... */],
providers: [
{
provide: APP_FILTER,
useClass: SentryGlobalFilter,
},
],
})
export class AppModule {}Steps to Reproduce
- Register
SentryGlobalFilteras a global exception filter - Have a service that makes HTTP calls with Axios (or any library whose errors have a
statusproperty) - Let an
AxiosErrorpropagate unhandled to the filter (e.g. a 404 from an upstream API)
// some.service.ts
import axios from 'axios';
@Injectable()
export class SomeService {
async callUpstreamApi() {
// This throws an AxiosError with { status: 404 } when the resource doesn't exist
await axios.put('https://some-api.example.com/resource/123', data);
}
}Expected Result
The AxiosError should be captured by Sentry since it is not a NestJS HttpException or RpcException — it is a genuine unexpected error from an upstream API call.
Actual Result
The error is silently dropped and never reported to Sentry. It only appears in application logs.
Root Cause
The isExpectedError helper (introduced in #13278) checks whether the exception object has a status or error property:
export function isExpectedError(exception: unknown): boolean {
if (typeof exception === 'object' && exception !== null) {
return 'status' in exception || 'error' in exception;
}
return false;
}This condition is very broad — status and error are extremely common property names on error objects. In practice this silently filters out AxiosError, and likely many other error types from database drivers, gRPC clients, or custom error classes that we'd want reported to Sentry.
Metadata
Metadata
Assignees
Labels
Projects
Status