-
Notifications
You must be signed in to change notification settings - Fork 962
fix(relay): carry binary tunnel WS frames as base64 #4066
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -191,9 +191,22 @@ export class TunnelClient { | |
| } | ||
|
|
||
| const localWs = new WebSocket(wsUrl.toString()); | ||
| localWs.binaryType = "arraybuffer"; | ||
|
|
||
| localWs.onmessage = (event) => { | ||
| this.send({ type: "ws:frame", id: request.id, data: String(event.data) }); | ||
| const data = event.data; | ||
| if (typeof data === "string") { | ||
| this.send({ type: "ws:frame", id: request.id, data }); | ||
| return; | ||
| } | ||
| if (data instanceof ArrayBuffer) { | ||
| this.send({ | ||
| type: "ws:frame", | ||
| id: request.id, | ||
| data: Buffer.from(data).toString("base64"), | ||
| encoding: "base64", | ||
| }); | ||
| } | ||
| }; | ||
|
Comment on lines
196
to
210
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If Prompt To Fix With AIThis is a comment left during a code review.
Path: packages/host-service/src/tunnel/tunnel-client.ts
Line: 196-210
Comment:
**Silent drop of unrecognised data types**
If `event.data` is neither a `string` nor an `ArrayBuffer`, the frame is silently discarded with no log entry. With `binaryType = "arraybuffer"` this case is currently unreachable in practice, but if the runtime or environment ever returns a `Buffer`/`Blob`, the PTY output will disappear without a trace. An `else` log helps diagnose future regressions.
How can I resolve this? If you propose a fix, please make it concise. |
||
|
|
||
| localWs.onclose = (event) => { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.