Repository: vscode
Issue: Apparent lifecycle discrepancy between `ManagementPersistentConnection` and  `ExtensionHostPersistentConnection`
Labels: bug,remote,remote-connection

<!-- ⚠️⚠️ 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?: Yes/No

<!-- 🪓 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.82.2
- OS Version: Linux

Steps to Reproduce:

1. Run vscode web with a workspace open
2. Leave the session running for a while but with the connection severed
3. Reconnect after more than 3 hours and observe that "session" is intact but extension host is gone

We have a setup where we use VSCode web to offer code editing. The system handles reconnection very well usually but we found a corner case in practice where somewhat randomly, people would come back to work the next day and notice that while their session from the day before appeared mostly intact (the window state was still there, document could be edited, ...), all extensions were gone in practice.

Digging into the source code this appears to be expected as the extension host will voluntarily shut itself off after 3 hours disconnected from its browser client:
https://github.com/microsoft/vscode/blob/dcd82219d6913026dca29cbb8204bd9e81c0eef1/src/vs/workbench/api/node/extensionHostProcess.ts#L148-L151

We can see this in our logs as well, where the message is reflected:
```
2023-11-22 02:15:34.564 [info] Extension host terminating: renderer disconnected for too long (1)
2023-11-22 02:15:34.607 [info] Extension host with pid 4158002 exiting with code 0
```

And when the browser does attempt to reconnect the next day we do see the message we would expect out of a `PersistentConnectionEventType.ReconnectionPermanentFailure` event:
```
2023-11-22 09:14:37.836 [info] Creating a socket (renderer-ExtensionHost-331c07c0-5fba-41a8-bb1c-047f5a04cdf0)...
2023-11-22 09:14:38.213 [info] Creating a socket (renderer-ExtensionHost-331c07c0-5fba-41a8-bb1c-047f5a04cdf0) was successful after 377 ms.
2023-11-22 09:14:38.396 [error] [remote-connection][ExtensionHost][331c0…][reconnect][WebSocket(<URL>:443)] received error control message when negotiating connection. Error:
2023-11-22 09:14:38.397 [error] Error: Connection error: Unknown reconnection token (seen before)
    at H (https://<URL>/stable-5e932f3b43c571637a183861652b0909ef6da48c/static/out/vs/workbench/workbench.web.main.js:657:25082)
    at o.value (https://<URL>/stable-5e932f3b43c571637a183861652b0909ef6da48c/static/out/vs/workbench/workbench.web.main.js:657:16703)
    at h.w (https://<URL>/stable-5e932f3b43c571637a183861652b0909ef6da48c/static/out/vs/workbench/workbench.web.main.js:70:1902)
    at h.fire (https://<URL>/stable-5e932f3b43c571637a183861652b0909ef6da48c/static/out/vs/workbench/workbench.web.main.js:70:2119)
    at s.fire (https://<URL>/stable-5e932f3b43c571637a183861652b0909ef6da48c/static/out/vs/workbench/workbench.web.main.js:596:13701)
    at b.z (https://<URL>/stable-5e932f3b43c571637a183861652b0909ef6da48c/static/out/vs/workbench/workbench.web.main.js:596:16800)
    at o.value (https://<URL>/stable-5e932f3b43c571637a183861652b0909ef6da48c/static/out/vs/workbench/workbench.web.main.js:596:16171)
    at h.w (https://<URL>/stable-5e932f3b43c571637a183861652b0909ef6da48c/static/out/vs/workbench/workbench.web.main.js:70:1902)
    at h.fire (https://<URL>/stable-5e932f3b43c571637a183861652b0909ef6da48c/static/out/vs/workbench/workbench.web.main.js:70:2119)
    at o.acceptChunk (https://<URL>/stable-5e932f3b43c571637a183861652b0909ef6da48c/static/out/vs/workbench/workbench.web.main.js:596:11475)
2023-11-22 09:14:38.397 [error] [remote-connection][ExtensionHost][331c0…][reconnect] A permanent error occurred in the reconnecting loop! Will give up now! Error:
2023-11-22 09:14:38.397 [error] Error: Connection error: Unknown reconnection token (seen before)
    at H (https://<URL>/stable-5e932f3b43c571637a183861652b0909ef6da48c/static/out/vs/workbench/workbench.web.main.js:657:25082)
    at o.value (https://<URL>/stable-5e932f3b43c571637a183861652b0909ef6da48c/static/out/vs/workbench/workbench.web.main.js:657:16703)
    at h.w (https://<URL>/stable-5e932f3b43c571637a183861652b0909ef6da48c/static/out/vs/workbench/workbench.web.main.js:70:1902)
    at h.fire (https://<URL>/stable-5e932f3b43c571637a183861652b0909ef6da48c/static/out/vs/workbench/workbench.web.main.js:70:2119)
    at s.fire (https://<URL>/stable-5e932f3b43c571637a183861652b0909ef6da48c/static/out/vs/workbench/workbench.web.main.js:596:13701)
    at b.z (https://<URL>/stable-5e932f3b43c571637a183861652b0909ef6da48c/static/out/vs/workbench/workbench.web.main.js:596:16800)
    at o.value (https://<URL>/stable-5e932f3b43c571637a183861652b0909ef6da48c/static/out/vs/workbench/workbench.web.main.js:596:16171)
    at h.w (https://<URL>/stable-5e932f3b43c571637a183861652b0909ef6da48c/static/out/vs/workbench/workbench.web.main.js:70:1902)
    at h.fire (https://<URL>/stable-5e932f3b43c571637a183861652b0909ef6da48c/static/out/vs/workbench/workbench.web.main.js:70:2119)
    at o.acceptChunk (https://<URL>/stable-5e932f3b43c571637a183861652b0909ef6da48c/static/out/vs/workbench/workbench.web.main.js:596:11475)
```

Now this might be ok and the right behavior to adopt (although I would love to be able to customize this somehow) but the main issue is that from a user perspective they find themselves in a situation where they end up using a half-broken VSCode instance where the main editing activities work fine (because the management connection doesn't have a timeout) but the extension host is never actually restarted unless the whole window is reloaded and so they have no intellisense feature.

If the intention is that the extension host should be able to be restarted after being shutdown in this manner then this doesn't seem to work currently.

If the intention is that the user should reload the tab, then [the code responsible for showing this hint](https://github.com/microsoft/vscode/blob/567021733ac110a958bafd5a9214a5350d9b243f/src/vs/workbench/contrib/remote/browser/remote.ts#L1003-L1017) currently only does it based on the state of the main management connection and not the state of the extension host.