Skip to content

Add support for One-Way WebSocket communication to backend #16775

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

Closed
3 of 4 tasks
Parkreiner opened this issue Mar 3, 2025 · 1 comment · Fixed by #16853
Closed
3 of 4 tasks

Add support for One-Way WebSocket communication to backend #16775

Parkreiner opened this issue Mar 3, 2025 · 1 comment · Fixed by #16853
Assignees
Labels
api Area: HTTP API

Comments

@Parkreiner
Copy link
Member

Parkreiner commented Mar 3, 2025

Turning this into a separate ticket to make it more clear what's been worked on since I started on #16518

Context

As mentioned in the parent ticket, we had a few assumptions about what was and wasn't possible about our WebSocket (WS) and Server-Sent Event (SSE) communication, and these ended up being wrong. Namely, we thought there was no good way to fix the root problem of the UI locking up when multiple tabs are opened, and the best we could do is create a UX band-aid to help direct users from hitting these edge cases.

It turns out, this is a problem that only exists with the Server-Sent Events protocol. Even on HTTP/1.1, all modern browsers support proper duplexing for socket connections. So naturally, if SSEs have the problem, and WSs don't, we can switch everything over to WebSockets.

Concerns

  • As of right now, the Coder SDK exposes a lot of Server-Sent Event concerns and types as public exports. We can't have any breaking API changes, so the best we can do is officially deprecate this functionality, and add documentation nudging people to favor WebSockets.

Tasks

  • Add OneWayWebSocket function that automatically handles upgrading an HTTP connection to WS, and handles all concurrency concerns
  • Add (non-flaky, concurrent) tests for OneWayWebSocket
  • Mark all previous SSE-based API routes as deprecated
  • Add new API routes that are WebSocket-based
@Parkreiner Parkreiner added the api Area: HTTP API label Mar 3, 2025
@Parkreiner Parkreiner self-assigned this Mar 3, 2025
@Parkreiner
Copy link
Member Author

Parkreiner commented Mar 3, 2025

Status update:

  • Tests are mostly done – there's just one case left that needs to be finished up . I'm running into a situation where the test output is +95% right, but some unexpected characters are getting added as bookends. It's fully possible that this is the correct behavior, and that there's parts of the WS protocol that I'm missing, but I need to verify that
  • Even with all the existing API endpoints still existing and being untouched, I'm running into test suite failures. If finishing up my new tests doesn't fix that, I'll need to see else needs to be addressed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Area: HTTP API
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant