-
Notifications
You must be signed in to change notification settings - Fork 874
Add support for One-Way WebSocket communication to frontend #16777
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
Comments
Status update:
Truth be told, if I knew for a fact that WebSocket integration tests weren't worth it, this could be a Complexity 1. But this was a case where it felt prudent to see what we could do to add tests, since the issues are all in service of fixing a problem being faced by multiple customers |
Wouldn't the server sent events be better than web sockets if only sever -> client one way connection is needed. |
@alihammad-gist You would think so, but there's actually a problem inherent to SSEs that doesn't exist with WebSockets. SSEs are still based on HTTP, so when the protocol is HTTP/1.1, it's still grouped with normal one-time server requests. And since browsers only allow 2–6 active HTTP connections per domain at a time, all you have to do is open Coder in multiple tabs, and that can cause the entire app to lock up WebSocket connections are still initiated via HTTP on HTTP/1.1, but because the connection type changes afterwards, browsers have much, much better multiplexing support To illustrate how different they are, I was able to set up 700 WebSocket connections for a single domain on HTTP/1.1 (100 connections per seven tabs), and there was zero issues. When I had seven SSE connections open (whether that was one connection per seven tabs, or seven connections all in the same tab), they all locked up It'd be nice if we didn't need these workarounds, but the SSE protocol is very old, and wasn't really made to handle these things. There's a reason why SSEs have warnings on their MDN documentation pages, while WebSockets don't |
Closes #16777 ## Changes made - Added `OneWayWebSocket` utility class to help enforce one-way communication from the server to the client - Updated all client client code to use the new WebSocket-based endpoints made to replace the current SSE-based endpoints - Updated WebSocket event handlers to be aware of new protocols - Refactored existing `useEffect` calls and removed some synchronization bugs - Removed dependencies and types for dealing with SSEs - Addressed some minor Biome warnings
Turning this into a separate ticket to make it more clear what's been worked on since I started on #16518
Context
This is basically the other half of #16775. That issue is for adding support for one-way websocket connections to the backend – this issue is for updating the frontend to be aware of those changes.
Tasks
OneWayWebSocket
class that takes the baseWebSocket
class, and prevents calling any methods that would send data back to the serverThe text was updated successfully, but these errors were encountered: