[BUG] Performance is atrocious on Remote-SSH w/ high latency connections
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
In vscode with Remote - SSH on a vpn with a long latency, around 500ms, the vscode extension has an extreme amount of UI lag. it can take 30+ minutes for permission dialogs to show up or for the claude ui to become aware of edits that have already happened according to the file explorer or editor. From extension.js analysis the reason is quite obvious:
sendQueue = Promise.resolve();
send(r) {
this.sendQueue = this.sendQueue.then(() => this.webview.postMessage({
type: "from-extension",
message: r
}).then(() => {}))
}
This code is wrong. To be specific, webview.postMessage immediately sends the given message and returns a Promise that resolves to true or false depending on if the message was "successfully delivered". Leaving aside that "successful" delivery is poorly defined, this serializes the transmission of the next message until after a full RTT from the previous message (the minimum time to receive any kind of delivery confirmation from the frontend). When we are sending many messages per second containing streaming tokens, this transmission queue will get very far behind.
What Should Happen?
Just call webview.postMessage immediately and discard the returned promise, which isn't actually useful for anything. In other words: don't serialize UI updates in this way. I patched my installation to do this and it greatly increases update throughput.
Error Messages/Logs
Steps to Reproduce
Use Remote - SSH to connect to a server, use a vpn or something with a sizeable rtt, I would suggest at least 500ms. Log into claude code, and ask Claude Haiku to produce "a very long poem, about 100 lines should do it". Observe that the result takes an extremely long time to display, for longer than Haiku takes to write it.
Claude Model
Not sure / Multiple models
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
2.1.17 (Claude Code for VS Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Other
Additional Information
_No response_
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗