Skip to content

perf: replace Rust WebSocket relay with direct Bun WS server for ExtHost IPC#513

Merged
j4rviscmd merged 2 commits intomainfrom
feat/bun-direct-ws
May 10, 2026
Merged

perf: replace Rust WebSocket relay with direct Bun WS server for ExtHost IPC#513
j4rviscmd merged 2 commits intomainfrom
feat/bun-direct-ws

Conversation

@j4rviscmd
Copy link
Copy Markdown
Owner

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

  • DELETE: ws_relay.rs, handshake.rs, protocol.rs, init_data.rs — entire Rust relay layer removed
  • NEW: exthostWsServer.tsBunWsSocket ISocket implementation + startWsServer() using Bun.serve() WebSocket
  • MODIFY: sidecar.rs — remove IPC pipe creation, pipe stdout for port reading via EXTHOST_WS_PORT:<port> protocol
  • MODIFY: spawn_exthost.rs — simplify to direct spawn + port read, remove relay logic
  • MODIFY: mod.rs — remove deleted modules, simplify ExtHostError enum
  • MODIFY: extensionHostProcess.ts — add WS server mode branch with isWsServerMode() check
  • MODIFY: tauriLocalProcessExtensionHost.ts — use spawn_exthost command directly, connect WebSocket to Bun's port
  • MODIFY: lib.rs — update command registration (remove spawn_exthost_with_relay)
  • MODIFY: Cargo.toml — remove tokio-tungstenite and futures-util dependencies

How to Test

  1. Build and launch the app: npm run tauri:devwin
  2. Verify the Extension Host activates successfully (check logs for [TauriExtHost] Received Initialized — handshake complete!)
  3. Verify extensions load and function correctly (try opening a file, using TypeScript IntelliSense, running a terminal)
  4. Verify clean shutdown — Bun process should terminate when the app exits
  5. Check that the Rust logs show WS port=<port> and no relay-related errors

…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]>
@j4rviscmd j4rviscmd added enhancement New feature or request area:extensions labels May 10, 2026
@j4rviscmd j4rviscmd merged commit 7056df6 into main May 10, 2026
7 checks passed
@j4rviscmd j4rviscmd deleted the feat/bun-direct-ws branch May 10, 2026 08:31
@j4rviscmd j4rviscmd mentioned this pull request May 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:extensions enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bun直接WebSocket通信(Rust WSリレー除去)

1 participant