perf: binary WebSocket transport for shell data#86
Merged
billchurch merged 3 commits intomainfrom Feb 7, 2026
Merged
Conversation
Accept binary frames from the server for shell output instead of JSON-wrapped UTF-8 strings. Socket.IO delivers server-side Buffers as ArrayBuffer in the browser; the client now detects the type and passes Uint8Array directly to xterm.js Terminal.write(), which has natively accepted binary input since xterm.js 4.0. String decoding (via TextDecoder) is deferred to the session logger and only runs when logging is active, keeping the display hot path allocation-free. The exec channel continues to receive strings since it accumulates output into a single result before emitting. Type signatures widened across the full write chain: - ServerToClientEvents.data: string → string | ArrayBuffer - socket.ts callbacks: string → string | Uint8Array - TerminalRef.write, TerminalActions.write, writeToTerminal: string → string | Uint8Array Refs: billchurch/webssh2#478
- @xterm/addon-fit 0.10.0 → 0.11.0 - @xterm/addon-search 0.15.0 → 0.16.0 - Fix high-severity ReDoS in @isaacs/brace-expansion (GHSA-7h2j-956f-4vf2) - Regenerate package-lock.json (npm audit fix triggered lockfile refresh)
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
Major version upgrade from xterm 5.5.0 to 6.0.0. No code changes required - all existing APIs remain compatible with our usage. Notable changes in v6: VS Code-style scrollbar, ESM support, synchronized output (DEC mode 2026), OSC 52 clipboard support.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
BufferasArrayBufferin the browser; client detects the type and passesUint8Arraydirectly to xterm.jsTerminal.write()TextDecoder) deferred to session logger, only when logging is activeTerminalRef.write,TerminalActions.write,SolidTerminalManager.writeToTerminalDOCS/SERVER_API.mdto document thestring | ArrayBufferpayloadCompanion to server-side changes on
fix/socket-backpressure-478in webssh2.Backwards compatibility
This client is backwards compatible with older servers — the
datahandler checksinstanceof ArrayBufferand falls through to the string path for servers that still emit strings.However, the server-side change (emitting raw
Bufferinstead of string) is not backwards compatible with older clients. Old clients pass theArrayBufferdirectly toterm.write(), which expectsstring | Uint8Array— resulting in garbled output. Server and client must be updated together.Test plan
npm run check:allpasses (lint + typecheck + 157 tests)npm run buildproduces clean outputcat /dev/urandom | hexdump -cshows reduced CPU usage (~25% vs 100% before)Refs: billchurch/webssh2#478