fix: WebSocket proxy drops text frames — receive_bytes() silently fails on auth token

terminal.js sends the ttyd auth token as a TEXT WebSocket frame. The proxy's
client_to_ttyd() called receive_bytes() which fails silently on text frames,
swallows the exception, and exits — auth never reached ttyd, ttyd never
started streaming, resulting in permanent black screen and reconnect loop.

Fix: use receive() and dispatch on message type, handling both bytes and text.
This commit is contained in:
Brian Krabach
2026-03-28 08:50:43 -07:00
parent 6cf54efcb5
commit 38c78fb575
2 changed files with 33 additions and 2 deletions
+5 -2
View File
@@ -365,8 +365,11 @@ async def terminal_ws_proxy(websocket: WebSocket) -> None:
async def client_to_ttyd() -> None:
try:
while True:
data = await websocket.receive_bytes()
await ttyd_ws.send(data)
msg = await websocket.receive()
if msg.get("bytes"):
await ttyd_ws.send(msg["bytes"])
elif msg.get("text"):
await ttyd_ws.send(msg["text"])
except Exception:
pass