ValidationPipe
and possibly others throw HttpException
when used on WS gateways
#13190
Open
3 of 15 tasks
Labels
needs triage
This issue has not been looked into
Is there an existing issue for this?
Current behavior
In the following example if the
ValidationPipe
was to ever throw, it would cause an internal error rather thenWsException
.To workaround this at the moment one possible solution is to patch it with an exception filter like so:
That's because by the looks of it
ValidationPipe
always throws anHttpException
regardless of the protocol of the current execution context.Minimum reproduction code
https://github.com/StiliyanKushev/ws-exception-validation-pipe-reproduction-repo
Steps to reproduce
Expected behavior
I expected
ValidationPipe
to throw aWsException
when used inside of a WS gateway.Package
@nestjs/common
@nestjs/core
@nestjs/microservices
@nestjs/platform-express
@nestjs/platform-fastify
@nestjs/platform-socket.io
@nestjs/platform-ws
@nestjs/testing
@nestjs/websockets
Other package
No response
NestJS version
10.3.0
Packages versions
Node.js version
No response
In which operating systems have you tested?
Other
Alternatively, if we're meant not to be using
ValidationPipe
on WS gateways, then the docs should be updated.As of now, the docs clearly showcase the possible use of
ValidationPipe
inside WS gateways as seen here:The text was updated successfully, but these errors were encountered: