Skip to content
This repository was archived by the owner on Sep 22, 2023. It is now read-only.

Commit 58a984d

Browse files
authored
fix: Write upstream websocket errors more reliably in the downstream (#144)
1 parent d47d262 commit 58a984d

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

changes/144.fix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Write upstream websocket errors more reliably to the client (browser) in the downstream

src/ai/backend/client/cli/app.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,13 @@ async def downstream():
106106
self.down_task = None
107107

108108
async def write_error(self, msg):
109+
if isinstance(msg.data, bytes):
110+
error_msg = msg.data.decode('utf8')
111+
else:
112+
error_msg = str(msg.data)
109113
rsp = 'HTTP/1.1 503 Service Unavailable\r\n' \
110-
'Connection: Closed\r\n\r\n' \
111-
'WebSocket reply: {}'.format(msg.data.decode('utf8'))
114+
'Connection: Closed\r\n\r\n' \
115+
'WebSocket reply: {}'.format(error_msg)
112116
self.writer.write(rsp.encode())
113117
await self.writer.drain()
114118

0 commit comments

Comments
 (0)