We are currently using Nest.JS as our backend solution for almost 2 years now. It worked pretty fine at all and didn’t gave us any big issues until this last week. As the title describes, it hangs out all on a sudden, without returning us any kind of log. We use it combined with pm2 and it is hosted on a aws t3.medium machine running ubuntu.
We are using the exception filter provided by nest.js in their documentation:
import {
ExceptionFilter,
Catch,
ArgumentsHost,
HttpException,
HttpStatus,
} from '@nestjs/common';
import { HttpAdapterHost } from '@nestjs/core';
@Catch()
export class AllExceptionsFilter implements ExceptionFilter {
constructor(private readonly httpAdapterHost: HttpAdapterHost) {}
catch(exception: unknown, host: ArgumentsHost): void {
// In certain situations `httpAdapter` might not be available in the
// constructor method, thus we should resolve it here.
const { httpAdapter } = this.httpAdapterHost;
const ctx = host.switchToHttp();
const httpStatus =
exception instanceof HttpException
? exception.getStatus()
: HttpStatus.INTERNAL_SERVER_ERROR;
const responseBody = {
statusCode: httpStatus,
timestamp: new Date().toISOString(),
path: httpAdapter.getRequestUrl(ctx.getRequest()),
};
httpAdapter.reply(ctx.getResponse(), responseBody, httpStatus);
}
}
It’s possible to log the reason why the application was shutdown and the specific route that gave us problem? It would be easier to fix that way.
Edit: We also have subscribed to Sentry, but those logs doesn't reach it as well.