Skip to content

Commit c86df52

Browse files
committed
docs: add comment about OOWS
1 parent 5065455 commit c86df52

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

coderd/httpapi/httpapi.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,15 @@ func WebsocketCloseSprintf(format string, vars ...any) string {
280280
return msg
281281
}
282282

283+
// OneWayWebSocket establishes a new WebSocket connection that enforces one-way
284+
// communication from the server to the client.
285+
//
286+
// We must use an approach like this instead of Server-Sent Events for the
287+
// browser, because on HTTP/1.1 connections, browsers are locked to no more than
288+
// six HTTP connections for a domain total, across all tabs. If a user were to
289+
// open a workspace in multiple tabs, the entire UI can start to lock up.
290+
// WebSockets have no such limitation, no matter what HTTP protocol was used to
291+
// establish the connection.
283292
func OneWayWebSocket[T any](rw http.ResponseWriter, r *http.Request) (
284293
sendEvent func(wsEvent T) error,
285294
closed chan struct{},

0 commit comments

Comments
 (0)