Express middleware `express-error-slack` doesn't work with NestJS, but works for express server
See original GitHub issueBug Report
Current behavior
NestJS documentation explains that nest Middleware is the same as express middleware. However, when trying to use the express-error-slack
middleware, it seems the function never gets called. This doesn’t seem to be a problem with the package itself, since the same package works as expected in express
https://github.com/chunkai1312/express-error-slack
Input Code
main.ts:
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { ValidationPipe } from '@nestjs/common';
import * as helmet from 'helmet';
import * as expressslack from 'express-error-slack';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.useGlobalPipes(new ValidationPipe());
app.use(expressslack({ webhookUri: 'webhookURL' }));
app.use(helmet());
await app.listen(3000);
}
bootstrap();
Controller
@Controller()
export class MyController {
@Get('error')
async error() {
throw new Error('Error!');
}
}
I would expect the express slack middleware to pick up the error and handle it, but it’s not
Environment
Nest version: 6
For Tooling issues:
- Node version: 10.15.1
- Platform: Windows 10
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Run express api server and socket alongside nest js?
I want to Implement a new module in nest js and run express, ... run express and nest on the same server but...
Read more >Nest.js Brings TypeScript to Node.js and Express - Auth0
Let's learn about Nest.js, the new framework that takes advantage of TypeScript to create reliable and well structured Express applications.
Read more >Interceptors | NestJS - A progressive Node.js framework
These details can be helpful in building more generic interceptors that can work across a broad set of controllers, methods, and execution contexts....
Read more >@nestjs/common - npm
A progressive Node.js framework for building efficient and scalable server-side applications. NPM Version Package License NPM Downloads ...
Read more >Getting started with continuous integration for Nest.js APIs
Developer A sits at a desk working on a beginning-level project. ... Nest.js is compatible with the majority of Express.js middleware.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@kamilmysliwiec I did not! Well I feel silly now. I will take ma look and verify this is what we’re looking for.
I also found a way to potentially do it with interceptors, was about to edit my response above with that information.
I still feel like the documentation should explicitly mention the issues with express error handling middleware. I assume there’s quite a few packages out there that wouldn’t work because of that. Unless I missed that in the documentation as well >.<
It’s actually a duplicate of this https://github.com/nestjs/docs.nestjs.com/issues/215