Repository: vscode
Issue: Can't upgrade on Debian 12.5: "Connection failed" to packages.microsoft.com
Labels: bug,install-update,confirmation-pending,deb

<!-- ⚠️⚠️ Do Not Delete This! bug_report_template ⚠️⚠️ -->
<!-- Please read our Rules of Conduct: https://opensource.microsoft.com/codeofconduct/ -->
<!-- 🕮 Read our guide about submitting issues: https://github.com/microsoft/vscode/wiki/Submitting-Bugs-and-Suggestions -->
<!-- 🔎 Search existing issues to avoid creating duplicates. -->
<!-- 🧪 Test using the latest Insiders build to see if your issue has already been fixed: https://code.visualstudio.com/insiders/ -->
<!-- 💡 Instead of creating your report here, use 'Report Issue' from the 'Help' menu in VS Code to pre-fill useful information. -->
<!-- 🔧 Launch with `code --disable-extensions` to check. -->
Does this issue occur when all extensions are disabled?: N/A

<!-- 🪓 If you answered No above, use 'Help: Start Extension Bisect' from Command Palette to try to identify the cause. -->
<!-- 📣 Issues caused by an extension need to be reported directly to the extension publisher. The 'Help > Report Issue' dialog can assist with this. -->
- VS Code Version: 1.87.2-1709912201
- OS Version: Debian 12.5

Steps to Reproduce:

1. `sudo apt update`
2. `sudo apt -y upgrade`

The package fails to download, with the following error:

```
  Connection failed [IP: 2620:1ec:bdf::69 443]
E: Failed to fetch https://packages.microsoft.com/repos/code/pool/main/c/code/code_1.87.2-1709912201_amd64.deb  Connection failed [IP: 2620:1ec:bdf::69 443]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
```

It turns out `apt` was able to fetch *exactly* 32 MiB of the package:

```
$ sudo ls -l /var/cache/apt/archives/partial
total 32768
-rw-r--r-- 1 root root 33554432 Mar 12 14:20 code_1.87.2-1709912201_amd64.deb
```

If I remove that file and retry, there's more evidence in the `apt` output of progress being made, but it still fails at exactly 32 MiB.

`wget` is able to complete the download, because it will attempt to resume when the connection is dropped. However, if prevented from doing so (with `-t1`), we can see that `wget` downloads of this file are terminated at exactly 72 MiB:

```
$ wget -t1 https://packages.microsoft.com/repos/code/pool/main/c/code/code_1.87.2-1709912201_amd64.deb
--2024-03-13 20:13:16--  https://packages.microsoft.com/repos/code/pool/main/c/code/code_1.87.2-1709912201_amd64.deb
Resolving packages.microsoft.com (packages.microsoft.com)... 2620:1ec:bdf::69, 2620:1ec:46::69, 13.107.246.69, ...
Connecting to packages.microsoft.com (packages.microsoft.com)|2620:1ec:bdf::69|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 99932898 (95M) [application/octet-stream]
Saving to: ‘code_1.87.2-1709912201_amd64.deb’

code_1.87.2-1709912201_amd6  75%[==============================>           ]  72.00M  37.8MB/s    in 1.9s    

2024-03-13 20:13:18 (37.8 MB/s) - Connection closed at byte 75497472. Giving up.
```

For comparison, `curl` is able to fetch exactly 32 MiB, just like `apt`:

```
$ curl https://packages.microsoft.com/repos/code/pool/main/c/code/code_1.87.2-1709912201_amd64.deb > somefile
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
 33 95.3M   33 32.0M    0     0  32.5M      0  0:00:02 --:--:--  0:00:02 32.5M
curl: (92) HTTP/2 stream 1 was not closed cleanly: INTERNAL_ERROR (err 2)
$ ls -l somefile
-rw-r--r-- 1 dave dave 33554432 Mar 13 20:15 why
```

The `curl` and `wget` commands are reproducible from other machines, including an old RaspbianOS machine.

Chrome is able to download the entire file without issue, as far as I can tell -- if it's retrying, it doesn't say so. I tried changing user-agents with `wget` and `curl`, including pasting Chrome's user-agent, and there's no difference.

Chrome is about the same size, and upgraded today on the same machine with no issues from apt. I tried fetching the Chrome Debian package with `wget` and `curl` and also had no problems. I also have no trouble with either `wget` or `curl` fetching the *initial* download -- e.g. if I open https://code.visualstudio.com/ and click the "deb" button, I get a link to https://vscode.download.prss.microsoft.com/dbazure/download/stable/863d2581ecda6849923a2118d93a088b0745d9d6/code_1.87.2-1709912201_amd64.deb which works fine from `wget` and `curl`. It's also exactly the same file, so it's only an issue with packages.microsoft.com.

However, other versions don't seem to have this issue. The previous build at https://packages.microsoft.com/repos/code/pool/main/c/code/code_1.87.2-1709911730_arm64.deb downloads fine with `wget`. It was slower at first, so I tried again, and it was just as fast as the current version.

You can see why I'm not including extensions or bisecting, as this isn't an issue with vscode itself, but with the Debian repository at packages.microsoft.com that vscode wants to update from.