Open zhukevgeniy opened 2 years ago
I'm trying to configure Sentry for nestjs application. I do not want to handle errors manually by using ::captureException. Instead, I want to send all my uncaught errors to the sentry.
::captureException
@Module({ imports: [ SentryModule.forRootAsync({ imports: [ConfigModule], useFactory: function (configService: ConfigService) { return { dsn: configService.get<string>('SENTRY_DSN'), environment: process.env.NODE_ENV, }; }, inject: [ConfigService], }), ConfigModule.forRoot({ isGlobal: true }), ], }) export class AppModule implements OnApplicationBootstrap { onApplicationBootstrap(): never { setTimeout(() => { throw new Error('Test error'); }, 0); } }
Current: Command failed with exit code 1 with no exception sent to sentry Expected: Command failed with exit code 1 and exception sent to sentry
Node version — 16.13.1
We need to flush the sentry and wait before we terminate the process.
// lib/sentry.service.ts (Sentry.getCurrentHub().getClient<Client<Options>>() as Client<Options>).captureException(err); await Sentry.flush(); // <----- flush here process.exit(1);
I don't think you're using the interceptor so nothing will get reported automatically. Look at the second message in this issue: https://github.com/ntegral/nestjs-sentry/issues/62
Input Code?
I'm trying to configure Sentry for nestjs application. I do not want to handle errors manually by using
::captureException
. Instead, I want to send all my uncaught errors to the sentry.Current and expected behavior
Current: Command failed with exit code 1 with no exception sent to sentry Expected: Command failed with exit code 1 and exception sent to sentry
Environment
Node version — 16.13.1
Possible solution
We need to flush the sentry and wait before we terminate the process.