perf: replace Rust WebSocket relay with direct Bun WS server for ExtHost IPC#513
Merged
perf: replace Rust WebSocket relay with direct Bun WS server for ExtHost IPC#513
Conversation
…ost IPC (#505) Remove the Rust WebSocket relay layer (ws_relay, handshake, protocol, init_data modules) and have Bun start its own WebSocket server that the WebView connects to directly. This eliminates an unnecessary hop and simplifies the architecture. - DELETE: ws_relay.rs, handshake.rs, protocol.rs, init_data.rs - NEW: exthostWsServer.ts (BunWsSocket ISocket impl + startWsServer) - MODIFY: sidecar.rs (remove IPC pipe, pipe stdout for port reading) - MODIFY: spawn_exthost.rs (simplify to direct spawn + port read) - MODIFY: mod.rs (remove deleted modules, simplify ExtHostError) - MODIFY: extensionHostProcess.ts (add WS server mode branch) - MODIFY: tauriLocalProcessExtensionHost.ts (use spawn_exthost directly) - MODIFY: lib.rs (update command registration) - MODIFY: Cargo.toml (remove tokio-tungstenite, futures-util) Co-Authored-By: Claude Opus 4.7 <[email protected]>
Co-Authored-By: Claude Opus 4.7 <[email protected]>
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
Remove the Rust WebSocket relay layer and have Bun start its own WebSocket server that the WebView connects to directly. This eliminates an unnecessary hop (WebView → WS → Rust relay → pipe → Bun becomes WebView → WS → Bun), reducing RPC round-trip latency for all extension host communication.
Closes #505
Related Issue
Closes #505 — parent epic: #504
Changes
ws_relay.rs,handshake.rs,protocol.rs,init_data.rs— entire Rust relay layer removedexthostWsServer.ts—BunWsSocketISocket implementation +startWsServer()usingBun.serve()WebSocketsidecar.rs— remove IPC pipe creation, pipe stdout for port reading viaEXTHOST_WS_PORT:<port>protocolspawn_exthost.rs— simplify to direct spawn + port read, remove relay logicmod.rs— remove deleted modules, simplifyExtHostErrorenumextensionHostProcess.ts— add WS server mode branch withisWsServerMode()checktauriLocalProcessExtensionHost.ts— usespawn_exthostcommand directly, connect WebSocket to Bun's portlib.rs— update command registration (removespawn_exthost_with_relay)Cargo.toml— removetokio-tungsteniteandfutures-utildependenciesHow to Test
npm run tauri:devwin[TauriExtHost] Received Initialized — handshake complete!)WS port=<port>and no relay-related errors