-
-
Notifications
You must be signed in to change notification settings - Fork 50
Open
Labels
Description
Is your feature request related to a problem? Please describe.
Currently an error in one of the uWebSockets handlers crashes the server, e.g. when getDoc fails in the open handler. So e.g. when a file for one room can't be retrieved from S3, the server crashes and all clients connected to other rooms also lose their connection.
Unfortunately I did not find a possibility to attach some kind of error handler like in express. (Or is there one? I'm rather new to uWebSockets.)
Describe alternatives you've considered
One way could be to wrap the code in the handlers in a try-catch and execute a given callback (that would be parameter of registerYWebsocketServer) in the catch, e.g.:
open: async (ws) => {
try {
const user = ws.getUserData()
...
} catch (error) {
errorCallback(error, ws)
}
},
AlexBSoft