【问题标题】:VSCode Slow to OpenVSCode 缓慢打开
【发布时间】:2021-05-31 23:44:40
【问题描述】:

我正在试用 WSL2 进行工作,并且我支持公司代理。我已经在 WSL 中配置了代理,因此互联网连接正常,并且我已将 no_proxy 设置如下

localhost,127.0.0.1,::1

当我使用命令 code . 从 wsl 打开 VSCode 时,大约需要一分钟才能打开。当我检查 VSCode 启动的日志时,它似乎正在尝试通过此地址连接到 WSL 上的服务器 172.17.164.22:36869

我的直觉是它与代理有关,但即使我将该 IP 地址添加到 no_proxy,它的行为也是一样的。从 WSL1 打开 VSCode 时没有延迟。一分钟后VSCode确实加载成功,我可以安装扩展没有问题,只是初始打开很慢。

我已尝试从 windows 和 WSL ping 该地址但均未识别,我按照日志中的建议在浏览器中尝试了它,它确实立即返回了一个 guid 外观的字符串

有什么想法吗?

[2021-03-02 11:39:09.199] Using shell environment from invoking shell: /tmp/vscode-distro-env.D9Yczp
[2021-03-02 11:39:09.392] Probing if server is already installed: C:\WINDOWS\System32\wsl.exe -d Ubuntu-20.04 -e sh -c "[ -d ~/.vscode-server/bin/622cb03f7e070a9670c94bae1a45d78d7181fbd4 ] && printf found || ([ -f /etc/alpine-release ] && printf alpine-; uname -m)"
[2021-03-02 11:39:09.573] Probing result: found
[2021-03-02 11:39:09.574] Server install found in WSL
[2021-03-02 11:39:09.575] Launching C:\WINDOWS\System32\wsl.exe -d Ubuntu-20.04 sh -c '"$VSCODE_WSL_EXT_LOCATION/scripts/wslServer.sh" 622cb03f7e070a9670c94bae1a45d78d7181fbd4 stable .vscode-server 0  '}
[2021-03-02 11:39:09.691] Setting up server environment: Looking for /home/barista/.vscode-server/server-env-setup. Not found.
[2021-03-02 11:39:09.691] WSL version: 4.19.128-microsoft-standard Ubuntu-20.04
[2021-03-02 11:39:09.691] WSL2-shell-PID: 627
[2021-03-02 11:39:09.691] Starting server: /home/barista/.vscode-server/bin/622cb03f7e070a9670c94bae1a45d78d7181fbd4/server.sh  --port=0 --use-host-proxy --without-browser-env-var --enable-remote-auto-shutdown 
[2021-03-02 11:39:09.992] 
[2021-03-02 11:39:09.992] 
[2021-03-02 11:39:09.992] *
[2021-03-02 11:39:09.992] * Visual Studio Code Server
[2021-03-02 11:39:09.992] *
[2021-03-02 11:39:09.992] * Reminder: You may only use this software with Visual Studio family products,
[2021-03-02 11:39:09.992] * as described in the license https://aka.ms/vscode-remote/license
[2021-03-02 11:39:09.992] *
[2021-03-02 11:39:09.992] 
[2021-03-02 11:39:09.992] IP Address: 172.17.164.22
[2021-03-02 11:39:09.992] Extension host agent listening on 36869
[2021-03-02 11:39:09.992] 
[2021-03-02 11:39:09.992] [11:39:09] Extension host agent started.
[2021-03-02 11:39:10.011] Pinging 172.17.164.22:36869...
[2021-03-02 11:40:25.179] 172.17.164.22:36869 no response
[2021-03-02 11:40:25.179] WSL resolver response: ::1:36869
[2021-03-02 11:40:25.179] To debug connection issues, open a local browser on http://[::1]:36869/version

【问题讨论】:

  • 您是否启用了代理? This post 有类似的问题,但这是由于代理配置造成的。

标签: visual-studio-code proxy wsl-2


【解决方案1】:

你的帖子让我想到了我最近遇到的一个问题。在我的情况下,我发现 VS Code 和 WSL2 要么会失去连接,要么会很慢地打开或加载扩展。

您的帖子提示我在连接和未连接 VPN 的情况下运行测试。我发现 VS Code 在连接我的 VPN 时启动非常缓慢,而且不在 VPN 上也可以。

然后我实现了 "remote.WSL.server.connectThroughLocalhost": true 设置(文件 > 首选项 > 设置,您可以从那里搜索),如 Github 上的 post 中所述。感谢 David 在他的帖子中提供了指向该问题的链接!

【讨论】:

  • 不客气!另外,从来不知道有那个选项!每次我想连接到 WSL 时,我都必须关闭我的代理。一定会试试看!谢谢!
猜你喜欢
  • 2012-05-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-07-31
  • 1970-01-01
  • 1970-01-01
  • 2013-12-07
相关资源
最近更新 更多