vscode
vscode copied to clipboard
User forwarded port has the first request TTFB too high
- VS Code Version:
Version: 1.56.2 (user setup) Commit: 054a9295330880ed74ceaedda236253b4f39a335 Date: 2021-05-12T17:13:13.157Z Electron: 12.0.4 Chrome: 89.0.4389.114 Node.js: 14.16.0 V8: 8.9.255.24-electron.0 OS: Windows_NT x64 10.0.19042 - OS Version:
Windows_NT x64 10.0.19042
Steps to Reproduce:
-
Forward the port of a container inside VSCode
-
Access it through browser

-
See that the first request has almost
400msof TTFB and the second one is less than10ms
Not sure we can make this any faster. On first connection we actually set up the port forwarding, so some time is required for that.
This feature request is now a candidate for our backlog. The community has 60 days to upvote the issue. If it receives 20 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our documentation.
Happy Coding!
Not sure we can make this any faster. On first connection we actually set up the port forwarding, so some time is required for that.
It is not only for the first-ever request but when we don't do a request, in like 10 seconds, it will take that 300+ms to respond, if I forward a port directly from docker-compose it will not have that issue, only when user-forwarded.
Here is another example, when I forward an simple NextJS server in VSCode:

Assigning to June to investigate further.
Looks like almost all of the time is spent here
https://github.com/microsoft/vscode/blob/ee1655a82ebdfd38bf8792088a6602c69f7bbd94/src/vs/platform/remote/common/remoteAgentConnection.ts#L363-L363
@alexdima I am not familiar with this function, but I suspect that there's nothing that can be done to speed it up since it all looks essential.
I'm having a similar issue with forwarded TCP connections being slow to connect to the inside container. I'm running on Windows in a remote container using docker. I'm running a webserver in the remote container with a very active rest API. Almost every TCP connection takes approximately 650ms to establish.
I've eliminated the extraneous players using netcat on each side to create a rudimentary echo server that confirms the 400-600ms delay.
I'm seeing the same behavior. Windows host, devcontainer in docker. I also have my apps running in docker, so essentially docker in docker. Accessing forwarded ports from host can take anywhere from almost instant to full timeout. Here's the behavior i'm observing:
- initial connection can take long time or can timeout.
- after a number of browser refreshes, it will eventually connect.
- i can now reload almost instantly all day long.
- if my app restarts, goto 1 (not every time).
- if i dont refresh for some time, goto 1 (fairly consistently).
I am seeing the same issue on the latest VS Code.
I have Remote SSH setup to a WSL instance on a different machine on my local network. When Port Forwarding through VSCode the initial TTFB on connection is slow.
However when setting the the port forwarding via Powershell SSH there are no issues.