vscode icon indicating copy to clipboard operation
vscode copied to clipboard

User forwarded port has the first request TTFB too high

Open Rechdan opened this issue 4 years ago • 8 comments

  • 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:

  1. Forward the port of a container inside VSCode

  2. Access it through browser

    image image

  3. See that the first request has almost 400ms of TTFB and the second one is less than 10ms

Rechdan avatar May 25 '21 13:05 Rechdan

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.

alexr00 avatar May 27 '21 13:05 alexr00

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!

vscode-triage-bot avatar May 27 '21 13:05 vscode-triage-bot

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.

Rechdan avatar May 27 '21 13:05 Rechdan

Here is another example, when I forward an simple NextJS server in VSCode: image

Rechdan avatar May 29 '21 02:05 Rechdan

Assigning to June to investigate further.

alexr00 avatar May 31 '21 09:05 alexr00

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.

alexr00 avatar Aug 19 '21 15:08 alexr00

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.

aughey avatar Aug 19 '22 15:08 aughey

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:

  1. initial connection can take long time or can timeout.
  2. after a number of browser refreshes, it will eventually connect.
  3. i can now reload almost instantly all day long.
  4. if my app restarts, goto 1 (not every time).
  5. if i dont refresh for some time, goto 1 (fairly consistently).

alexgorbatchev avatar Apr 05 '23 00:04 alexgorbatchev

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.

Plinpod avatar May 21 '25 16:05 Plinpod