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
{{ message }}
This repository has been archived by the owner on Apr 7, 2022. It is now read-only.
Since the rest of Vapor is very asynchronous with many tasks returning futures, it makes it difficult to work with web sockets. Maybe this just requires more examples in the documentation, though it would be nice if web sockets got some love like the rest of Vapor.
If you need to do a query in one of the following examples, there is no where to return the future. I've run in to leaking promises and other issues because of this.
func onUpgrade(ws:WebSocket, req:Request)throws
ws.onText{(ws, text)in
// no where to return future
}
Could this get addressed in Vapor 4?
The text was updated successfully, but these errors were encountered:
This could be possible, if we can figure out a sensible way for the closure to handle a failed future. Something like logging the error then closing the WebSocket?
I'm not sure how useful that would be though since one would probably want better error handling logic for their client's sake. Which you can do currently with something like:
ws.onText{(ws, text) in
someAsyncThing().do { res in
ws.send("res is: \(res") }.catch { error in ws.send("oops:\(error)") ws.close() }}
I like @calebkleveter's idea, though don't know if that would be possible. Plus we already have WebSocket.onError and it's used for when the connection itself has an error.
But one place to handle errors from futures, or maybe an error middleware for web sockets would be nice.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Since the rest of Vapor is very asynchronous with many tasks returning futures, it makes it difficult to work with web sockets. Maybe this just requires more examples in the documentation, though it would be nice if web sockets got some love like the rest of Vapor.
If you need to do a query in one of the following examples, there is no where to return the future. I've run in to leaking promises and other issues because of this.
Could this get addressed in Vapor 4?
The text was updated successfully, but these errors were encountered: