fix: handle unhandled exceptions (#1116)

* Handle unhandled exceptions
* cleanup
This commit is contained in:
Philip Okugbe
2025-04-29 23:29:00 +01:00
committed by GitHub
parent 9bbd62e0f0
commit e8847bd9cd
3 changed files with 20 additions and 8 deletions

View File

@ -4,12 +4,7 @@ import {
FastifyAdapter,
NestFastifyApplication,
} from '@nestjs/platform-fastify';
import {
Logger,
NotFoundException,
RequestMethod,
ValidationPipe,
} from '@nestjs/common';
import { Logger, NotFoundException, ValidationPipe } from '@nestjs/common';
import { TransformHttpResponseInterceptor } from './common/interceptors/http-response.interceptor';
import { WsRedisIoAdapter } from './ws/adapter/ws-redis.adapter';
import { InternalLogFilter } from './common/logger/internal-log-filter';
@ -92,6 +87,14 @@ async function bootstrap() {
const logger = new Logger('NestApplication');
process.on('unhandledRejection', (reason, promise) => {
logger.error(`UnhandledRejection: ${promise}, reason: ${reason}`);
});
process.on('uncaughtException', (error) => {
logger.error('UncaughtException:', error);
});
const port = process.env.PORT || 3000;
await app.listen(port, '0.0.0.0', () => {
logger.log(