You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[ ] Regression
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
Current behavior
If I return an observable that errors from within a @WebsocketGateway method that has @SubscribeMessage, the server crashes rather than invoking an error handler.
Expected behavior
Either the global error handler should catch the error and emit it to the client, or if set, the custom WsException.catch method should be invoked with the error.
Minimal reproduction of the problem with instructions
import{Injectable,UseFilters}from'@nestjs/common';import{OnGatewayInit,SubscribeMessage,WebSocketGateway,WebSocketServer,WsResponse}from'@nestjs/websockets';import{Observable,throwError}from'rxjs';import{map}from'rxjs/operators';import{Namespace,Socket}from'socket.io';
@WebSocketGateway()exportclassSocketGateway{
@SubscribeMessage('ping')publicpong(client: Socket,data: any,): Observable<WsResponse<any>>{returnthrowError();// this causes server crash, not a handled exception}}
Environment
Nest version: 5.3.0
The text was updated successfully, but these errors were encountered:
zakhenry
changed the title
Observable errors from websocket @SubscribeMessage are not caught by exception filters
Observable errors from websocket @SubscribeMessage are not caught by exception filters, causing server crash
Nov 13, 2018
I'm submitting a...
Current behavior
If I return an observable that errors from within a
@WebsocketGateway
method that has@SubscribeMessage
, the server crashes rather than invoking an error handler.Expected behavior
Either the global error handler should catch the error and emit it to the client, or if set, the custom WsException.catch method should be invoked with the error.
Minimal reproduction of the problem with instructions
Environment
The text was updated successfully, but these errors were encountered: