Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling of errors in uWebSockets handlers #30

Open
dyedwiper opened this issue Aug 19, 2024 · 1 comment
Open

Handling of errors in uWebSockets handlers #30

dyedwiper opened this issue Aug 19, 2024 · 1 comment
Assignees

Comments

@dyedwiper
Copy link

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
Copy link

This is very critical problem for me that server always crashes in my project. Don't know how to fix this yet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants