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
+28
View File
@@ -0,0 +1,28 @@
"""
Regression tests for the WebSocket proxy in muxplex/main.py.
"""
import inspect
from muxplex.main import terminal_ws_proxy
def test_terminal_ws_proxy_does_not_use_receive_bytes():
"""Regression: receive_bytes() silently drops TEXT frames (like the ttyd auth token).
terminal.js sends {"AuthToken": ""} as a TEXT WebSocket frame. The original
proxy used receive_bytes() which fails on text frames, swallowed the exception,
and exited — meaning ttyd never received the auth token, never started
streaming, resulting in a permanent black screen and reconnect loop.
The proxy MUST use receive() and dispatch on message type to handle both
binary and text frames correctly.
"""
source = inspect.getsource(terminal_ws_proxy)
assert "receive_bytes" not in source, (
"client_to_ttyd must not use receive_bytes() — silently drops text frames "
'like the ttyd auth token {"AuthToken": ""}'
)
assert ".receive()" in source, (
"client_to_ttyd must use receive() to handle both text and binary frames"
)