Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.

Commit 035c320

Browse files
myan9starpit
authored andcommitted
fix(plugins/plugin-bash-like): reloading browser when streaming events may cause websocket channel to crash
Fixes #6608
1 parent 0351e9f commit 035c320

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

plugins/plugin-bash-like/src/pty/websocket-channel.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,12 @@ class WebSocketChannel implements Channel {
5151
uid: this.uid,
5252
gid: this.gid
5353
})
54-
return this.ws.send(JSON.stringify(withUser))
54+
// message from Kui proxy process that we are retransmitting to the browser
55+
try {
56+
return this.ws.send(JSON.stringify(withUser))
57+
} catch (err) {
58+
console.error('Error from WebSocketChannel:', err)
59+
}
5560
}
5661

5762
get readyState(): number {
@@ -66,11 +71,13 @@ class WebSocketChannel implements Channel {
6671
// eslint-disable-next-line @typescript-eslint/no-explicit-any
6772
on(eventType: string, handler: any) {
6873
switch (eventType) {
74+
// new Kui browser client
6975
case 'open':
7076
debug('WebSocketChannel: installing onopen handler')
7177
this.ws.addEventListener(eventType, handler)
7278
break
7379

80+
// message from Kui browser client
7481
case 'message':
7582
debug('WebSocketChannel: installing onmessage handler')
7683
// this.onmessage = message => handler(message.data)

0 commit comments

Comments
 (0)