Closed xadamxk closed 7 months ago
Please provide a minimum reproduction repository. You can start one by running npm init nest
in your terminal
@micalevisk I've updated the original issue to include a complete sample project: https://github.com/xadamxk/nestjs-filterbug-reproduction.
https://github.com/nestjs/nest/issues/9372 https://github.com/nestjs/nest/issues/3252
This is the expected behavior (filters execution is not chained; only 1 is executed per exception)
This is the expected behavior (filters execution is not chained; only 1 is executed per exception)
I don't expect the filter execution to be chained, but I do expect the application to pass the exception to a filter if the specified exception matches. In my example, only 1 filter is able to be used in my application while the documentation states that multiple filters are supported.
You can add as many filters with this technique as needed; simply add each to the providers array.
The auth.filter
in my sample project should be triggering and it isn't. Am I misunderstanding or is that actually expected? Thanks for your help.
@micalevisk @kamilmysliwiec could you review my most recent comment please?
It'd be nice if the error would be back in the flow of filters when the catch()
would again throw exception
(or return Promise.reject(exception)
)
Is there an existing issue for this?
Current behavior
If more than one APP_FILTER providers are provided, only the last one gets triggered.
Minimum reproduction code
https://github.com/xadamxk/nestjs-filterbug-reproduction https://gist.github.com/xadamxk/0d4648a79e708b6957b976ae54b3b271
Steps to reproduce
AuthExceptionFilter
is registered to catch (ie.ForbiddenException
) in a controllerconsole.log("in auth-filter");
is never ran, butconsole.log("in global-filter");
isExpected behavior
I would expect the first filter (
AuthExceptionFilter
) to run if an exception matches it's provided exception list. And if not, the next/last filter (GlobalExceptionFilter
) would run.Package
Other package
No response
NestJS version
10.3.5
Packages versions
Node.js version
18.19.1 (tried 20.x as well)
In which operating systems have you tested?
Other
I found the same issue from 6 years ago, which was said to be fixed in 5.1.0, but I am running into the exact same problem now.