microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
160.2k stars 28.06k forks source link

In WSL intermittently VS Code is not able to connect to different extensions requiring access to Github APIs like Github Copilot, Gitlens Launchpad #216658

Open NehalDamania opened 1 week ago

NehalDamania commented 1 week ago

Does this issue occur when all extensions are disabled?: Yes/No

Steps to Reproduce:

  1. Open VSCode add folder from WSL
  2. Install Github copilot, Gitlens
  3. Intermittently Github copilot chat or copilot or Gitlens Launchpad, or other will stop working or will not start intermittently
  4. VS Code without WSL works without any issues.

Why I think this might be VS Code issue and not plugin issue:

  1. Different plugins like Github Copilot as well as Gitlens launchpad, Github Pull requests all stop working.
  2. However, these all work fine in normal windows environment without WSL.
  3. Sometimes the above plugin works, when Wi-Fi network is changed, but intermittently it stops working on the changed network too. It continues to work seemlessly in VSCode without WSL
  4. This was working fine without any issues till few days back on WSL. I think maybe before this update everything was working fine.
copdips commented 1 week ago

I have similar issue, copilot worked well previously, but it seems that sinice one month or two, it doesn't work anymore in WSL.

copdips commented 1 week ago

Very strange, I retested by changing my internet access to mobile phone, and it worked. Changing back to home internet, the issue arises agains.

It seems to be an internet firewall issue, which is very strange. Either my home internet box is blocking copilot, or github copilot is blocking my home internet IP (I'm not using any VPN, just a simple direct connection).

Can we check the IP? I can share it with you with a private message.

please find hereunder the outputs when using mobile phone internet which worked:

Github Copilot output:

2024-06-24 14:58:10.644 [error] [auth] Extension activation failed: "FetchError"
2024-06-24 14:58:14.316 [error] [default] Error sending telemetry FetchError: 
    at fetch (/home/xiang/.vscode-server/extensions/github.copilot-1.206.0/node_modules/@adobe/helix-fetch/src/fetch/index.js:99:11)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at runNextTicks (node:internal/process/task_queues:64:3)
    at listOnTimeout (node:internal/timers:540:9)
    at processTimers (node:internal/timers:514:7)
    at cachingFetch (/home/xiang/.vscode-server/extensions/github.copilot-1.206.0/node_modules/@adobe/helix-fetch/src/fetch/index.js:288:16)
    at xq.fetch (/home/xiang/.vscode-server/extensions/github.copilot-1.206.0/lib/src/network/helix.ts:88:22) {
  type: 'system',
  _name: 'FetchError',
  code: 'ETIMEDOUT',
  errno: undefined,
  erroredSysCall: undefined
}
2024-06-24 14:58:15.853 [error] [auth] Retrying auth
2024-06-24 14:58:31.586 [info] [fetcher] Using Helix fetcher, Electron fetcher is not available.
2024-06-24 14:58:31.586 [info] [code-referencing] Public code references are enabled.
2024-06-24 14:58:31.594 [info] [fetcher] Using Helix fetcher, Electron fetcher is not available.
2024-06-24 14:58:31.594 [info] [code-referencing] Public code references are enabled.
2024-06-24 14:58:31.599 [info] [fetcher] Using Helix fetcher, Electron fetcher is not available.
2024-06-24 14:58:31.599 [info] [code-referencing] Public code references are enabled.

Github Copilot Chat output:

2024-06-24 14:58:08.996 [info] [FetcherService] Using the Helix fetcher.
2024-06-24 14:58:08.996 [info] [gitExtensionService] Initializing Git extension service.
2024-06-24 14:58:08.996 [info] [gitExtensionService] Successfully activated the vscode.git extension.
2024-06-24 14:58:08.996 [info] [gitExtensionService] Enablement state of the vscode.git extension: true.
2024-06-24 14:58:08.996 [info] [gitExtensionService] Successfully registered Git commit message provider.
2024-06-24 14:58:08.996 [info] [auth] Logged in as copdips
2024-06-24 14:58:10.785 [info] [extension] GitHub Copilot could not connect to server. Extension activation failed: "ate"
2024-06-24 14:58:14.438 [info] [auth] Logged in as copdips
2024-06-24 14:58:15.619 [info] [chat] copilot token chat_enabled: true
2024-06-24 14:58:15.619 [info] [githubTitleAndDescriptionProvider] Initializing GitHub PR title and description provider provider.
2024-06-24 14:58:15.659 [info] [auth] Got Copilot token for copdips
2024-06-24 14:58:15.994 [info] [auth] Logged in as copdips
2024-06-24 14:58:16.010 [info] [chat] copilot token chat_enabled: true
2024-06-24 14:58:16.010 [info] [auth] Got Copilot token for copdips
2024-06-24 14:58:17.499 [info] [RemoteAgents] Failed to load remote slash commands: ate
2024-06-24 14:58:17.718 [info] [githubTitleAndDescriptionProvider] Successfully activated the GitHub.vscode-pull-request-github extension.
2024-06-24 14:58:17.718 [info] [githubTitleAndDescriptionProvider] Successfully registered GitHub PR title and description provider.
2024-06-24 14:58:30.678 [info] [auth] Logged in as copdips
2024-06-24 14:58:30.684 [info] [auth] Logged in as copdips
2024-06-24 14:58:31.427 [info] [chat] copilot token chat_enabled: true
2024-06-24 14:58:31.428 [info] [auth] Got Copilot token for copdips
2024-06-24 14:58:31.459 [info] [chat] copilot token chat_enabled: true
2024-06-24 14:58:31.459 [info] [auth] Got Copilot token for copdips

And please find the diag info:

Details ## Copilot - Version: 1.206.0 - Build: prod - Editor: vscode/1.90.2 ## Environment - http_proxy: n/a - https_proxy: n/a - no_proxy: n/a - SSL_CERT_FILE: n/a - SSL_CERT_DIR: n/a - OPENSSL_CONF: n/a ## Feature Flags ## Node setup - Number of root certificates: 146 - Operating system: Linux - Operating system version: 5.15.153.1-microsoft-standard-WSL2 - Operating system architecture: x64 - NODE_OPTIONS: n/a - NODE_EXTRA_CA_CERTS: n/a - NODE_TLS_REJECT_UNAUTHORIZED: n/a - tls default min version: TLSv1.2 - tls default max version: TLSv1.3 ## Network Configuration - Proxy host: n/a - Proxy port: n/a - Kerberos SPN: n/a - Reject unauthorized: disabled - Fetcher: HelixFetcher ## Reachability - github.com: The operation was aborted. - copilot-proxy.githubusercontent.com: The operation was aborted. - api.githubcopilot.com: The operation was aborted. - default.exp-tas.com: The operation was aborted. ## VS Code Configuration - HTTP proxy: - HTTP proxy authentication: n/a - Proxy Strict SSL: true - Extension HTTP proxy support: override ## Extensions - Is `win-ca` installed?: false - Is `mac-ca` installed?: false ## Authentication - GitHub username: copdips
NehalDamania commented 1 week ago

I am getting exactly the same issue. Sometimes it works on mobile internet. And on Wi-Fi it stops. Rarely it connects via wifi. But the issue happens only on WSL.

copdips commented 6 days ago

let me recap some tests from the same laptop (Windows 11):

Internet \ OS Windows WSL
Fixed OK Failed
Mobile OK OK
copdips commented 6 days ago

ok, I just did more tests, it seems to be a WSL DNS issue.

> cat /etc/resolv.conf
# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateResolvConf = false
nameserver 10.255.255.254
search home

I added nameserver 1.1.1.1 before nameserver 10.255.255.254 then the issue was resolved. In WSL, to make this change valid, I must also edit the file /etc/wsl.conf as explained by the output of cat /etc/resolv.conf

Now, I have.

> cat /etc/resolv.conf 
nameserver 1.1.1.1
nameserver 10.255.255.254
search home
> cat /etc/wsl.conf 
[boot]
systemd=true

[user]
default=xiang

[network]
generateResolvConf = false

With nameserver 10.255.255.254 only, it can resolve github.com, but github copilot might use other domains too that I'm not aware, the extension output doesn't provide such details.

TylerLeonhardt commented 6 days ago

Well this is very bizarre. @aeschli or @connor4312 with your WSL experience, have you seen something like this before/have any ideas?

NehalDamania commented 6 days ago

let me recap some tests from the same laptop (Windows 11):

Internet \ OS Windows WSL Fixed OK Failed Mobile OK OK

Exactly same for me, it works on Mobile internet connection, but does not work on Fixed Internet connection. Unfortunately the etc/resolv.conf fix given above is not working for me. On fixed connection it still does not work.

In fact, once I restart wsl, by running the wsl --shutdown command and then starting a new wsl terminal, And, then with generateResolvConf = false line in the /etc/wsl.conf file, wsl is not even recreating resolv.conf. And the saved one before is getting deleted. May be some WSL issue.

copdips commented 6 days ago

yes you need to generate by yourself the file resolv.conf after altering wsl.conf

NehalDamania commented 6 days ago

yes you need to generate by yourself the file resolv.conf after altering wsl.conf

Thank you. Do I need to regenerate manually everytime wsl is restarted?

copdips commented 6 days ago

no just once

copdips commented 6 days ago

I notice that, the DNS server 10.255.255.254 is a secondary IP bound to my loopback interface inside WSL set automatically by WSL (when generateResolvConf = false is not set in /etc/wsl.conf ).

Meanwhile, my Windows OS' DNS server is the one of my home internet box (WIFI with DHCP) which is 192.168.111.1.

What're the default contents of your /etc/resolv.conf ?

WSL:

$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet 10.255.255.254/32 brd 10.255.255.254 scope global lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 00:15:5d:4c:0d:65 brd ff:ff:ff:ff:ff:ff
    inet 172.27.15.111/20 brd 172.27.15.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::215:5dff:fe4c:d65/64 scope link 
       valid_lft forever preferred_lft forever

Windwos OS:

PS C:\Users\xiang> Get-NetIPConfiguration

InterfaceAlias       : Wi-Fi
InterfaceIndex       : 4
InterfaceDescription : Intel(R) Wi-Fi 6 AX201 160MHz
NetProfile.Name      : poslsfmwianciq
IPv6Address          : 2a01:xxxxxxxxxxx
IPv4Address          : 192.168.111.47
IPv6DefaultGateway   : fe80::d6f8:29ff:fe80:78c0
IPv4DefaultGateway   : 192.168.111.1
DNSServer            : 2a01:cb08:e25:1700:d6f8:29ff:fe80:78c0
                       fe80::d6f8:29ff:fe80:78c0
                       192.168.111.1

InterfaceAlias       : Ethernet 2
InterfaceIndex       : 5
InterfaceDescription : Realtek USB GbE Family Controller #2
NetAdapter.Status    : Disconnected

InterfaceAlias       : Connexion réseau Bluetooth
InterfaceIndex       : 8
InterfaceDescription : Bluetooth Device (Personal Area Network)
NetAdapter.Status    : Disconnected

InterfaceAlias       : Connexion au réseau local 2
InterfaceIndex       : 23
InterfaceDescription : OpenVPN Data Channel Offload
NetAdapter.Status    : Disconnected

InterfaceAlias       : Astrill VPN
InterfaceIndex       : 25
InterfaceDescription : Wintun Userspace Tunnel
NetAdapter.Status    : Disconnected
NehalDamania commented 5 days ago

Hi, My default /etc/resolv.conf is

# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateResolvConf = false
nameserver 10.255.255.254
search hgu_lan

Same as yours. ip addr

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet 10.255.255.254/32 brd 10.255.255.254 scope global lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 00:15:5d:f3:59:96 brd ff:ff:ff:ff:ff:ff
    inet 172.30.31.161/20 brd 172.30.31.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::215:5dff:fef3:5996/64 scope link
       valid_lft forever preferred_lft forever
alexdima commented 5 days ago

@copdips It looks like you've found a workaround to the DNS problem and are unblocked.

@NehalDamania Is your fixed connection configured to use proxies or something special? Can you try to run from inside WSL curl https://api.githubcopilot.com/_ping

chrmarti commented 5 days ago

We have seen reports suggesting that something with ipv6 changed in WSL. Could you run these commands to see if they use (or see) ipv6 addresses:

copdips commented 5 days ago

hello,

I tested in the 2 senarios (DNS handled by /ect/wsl.conf, and DNS handled manually by me), after a diff check, they got the same ouputs, I will show you the bad one (DNS handled by /etc/wsl.conf) below:

10:55 $ curl -v my.ip.fi
*   Trying 91.198.120.42:80...
* TCP_NODELAY set
* Connected to my.ip.fi (91.198.120.42) port 80 (#0)
> GET / HTTP/1.1
> Host: my.ip.fi
> User-Agent: curl/7.68.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Server: nginx/1.18.0
< Date: Fri, 28 Jun 2024 08:55:46 GMT
< Content-Type: text/html;charset=utf-8
< Content-Length: 12
< Connection: keep-alive
< X-XSS-Protection: 1; mode=block
< X-Content-Type-Options: nosniff
< X-Frame-Options: SAMEORIGIN
< Strict-Transport-Security: max-age=3600
< Upgrade-Insecure-Requests: 1
<
[my public IPv4 (not IPv6) masked]
* Connection #0 to host my.ip.fi left intact
✔ /mnt/c/Users/xiang
10:55 $ curl -v https://api.githubcopilot.com/_ping
*   Trying 140.82.114.21:443...
* TCP_NODELAY set
* Connected to api.githubcopilot.com (140.82.114.21) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: /etc/ssl/certs
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_128_GCM_SHA256
* ALPN, server accepted to use h2
* Server certificate:
*  subject: C=US; ST=California; L=San Francisco; O=GitHub, Inc.; CN=*.githubcopilot.com
*  start date: Aug 16 00:00:00 2023 GMT
*  expire date: Aug 16 23:59:59 2024 GMT
*  subjectAltName: host "api.githubcopilot.com" matched cert's "*.githubcopilot.com"
*  issuer: C=US; O=DigiCert Inc; CN=DigiCert Global G2 TLS RSA SHA256 2020 CA1
*  SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x55b34f4a50e0)
> GET /_ping HTTP/2
> Host: api.githubcopilot.com
> user-agent: curl/7.68.0
> accept: */*
>
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* old SSL session ID is stale, removing
* Connection state changed (MAX_CONCURRENT_STREAMS == 100)!
< HTTP/2 200
< date: Fri, 28 Jun 2024 08:55:59 GMT
< content-length: 2
< content-type: text/plain; charset=utf-8
< x-github-backend: Kubernetes
< x-github-request-id: CF04:18C6F0:1182239:1870D88:667E7A9F
<
* Connection #0 to host api.githubcopilot.com left intact
OK✔ /mnt/c/Users/xiang
10:55 $ cat /etc/resolv.conf
# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateResolvConf = false
nameserver 10.255.255.254
search home
NehalDamania commented 4 days ago

curl https://api.githubcopilot.com/_ping

it is returning OK, on fixed line.

> curl https://api.githubcopilot.com/_ping                                                                                                                                                                    
OK

But VS Code Copilot plugin not working though inside WSL

NehalDamania commented 4 days ago
  • curl -v my.ip.fi

    
    curl -v my.ip.fi                                                                                                                                                                                            
  • Trying 91.198.120.42:80...

  • TCP_NODELAY set

  • Connected to my.ip.fi (91.198.120.42) port 80 (#0) GET / HTTP/1.1 Host: my.ip.fi User-Agent: curl/7.68.0 Accept: /

  • Mark bundle as not supporting multiuse < HTTP/1.1 200 OK < Server: nginx/1.18.0 < Date: Fri, 28 Jun 2024 13:01:55 GMT < Content-Type: text/html;charset=utf-8 < Content-Length: 16 < Connection: keep-alive < X-XSS-Protection: 1; mode=block < X-Content-Type-Options: nosniff < X-Frame-Options: SAMEORIGIN < Strict-Transport-Security: max-age=3600 < Upgrade-Insecure-Requests: 1 < x.x.x.x

  • Connection #0 to host my.ip.fi left intact

chrmarti commented 4 days ago

Could you install the latest VS Code Insiders (https://code.visualstudio.com/insiders/) and the latest GitHub Copilot Chat pre-release (currently v0.17.2024062801), run F1 > Developer: GitHub Copilot Chat Diagnostics and share the output here?

NehalDamania commented 4 days ago

Github Copilot Chat and Github copilot is working perfectly fine in VS Code Insiders. Here is the diagnostics output:

GitHub Copilot Chat

Network

User Settings:

  "github.copilot.advanced": {
    "debug.useElectronFetcher": false,
    "debug.useNodeFetcher": false
  }

DNS Lookup api.githubcopilot.com: 140.82.113.21

Fetching https://api.githubcopilot.com/_ping:

chrmarti commented 1 day ago

@NehalDamania Not sure what might make the difference. VS Code 1.91 is expected later this week. Maybe you can use VS Code Insiders until then. If it then doesn't work in 1.91 it might be a configuration issue or maybe another extension causing it.

NehalDamania commented 1 day ago

@NehalDamania Not sure what might make the difference. VS Code 1.91 is expected later this week. Maybe you can use VS Code Insiders until then. If it then doesn't work in 1.91 it might be a configuration issue or maybe another extension causing it.

Thank you @chrmarti . Yes, I am using insiders now. It is working fine. Once, 1.91 releases, I will post an update on whether the issue gets resolved or not. Once again thanks