Steps to Reproduce:
In the morning, VS Code says it's lost its connection with WSL and needs to reload the window. However, calling wsl -l -v shows that the WSL 2 VM is indeed still running.
I've written about Modern Standby specifically because I don't know if this behavior occurs with normal standby as well, but I imagine it's probably specific to Modern Standby because Windows is still active there, but not during normal standby afaik.
@aeschli Is this just another variation of challenges with reconnecting after sleep?
Seems like the WSL remote extension is using TCP/IP for the connectivity to the WSL 2 container. When the system enters modern standby, Hyper-V will pause running VMs and Hyper-V-VmSwitch will "disconnect" itself from host. On a system with plenty of virtual switches, Hyper-V will sometimes takes a full minute to restore connectivity of all of those virtual switches, further exaggerating this problem.
Replacing TCP/IP sockets with the Hyper-V sockets (AF_VSOCK on the Linux side and AF_HYPERV on the Windows side) instead of the regular TCP/IP should solve this problem.
Let see if increasing the timeout helps
I wasn't able to reproduce the issue.
Lately I have found that this issue does not always occur, or at least it seems to happens less frequently. Perhaps something seemingly unrelated somehow mitigated this to a degree. I'll try to see if I find a pattern, and will try to get a better idea of how often it still occurs.
Issue happened (much) less often if I can get Hyper-V virtual switches to wake up faster, in case of short modern standby sessions. (e.g. the typical duration of lunch break, commuting, etc.). Several ways that I can do to speed this up are:
NetSetupSvc after WSL 2 is started.Keeping the system for an extended amount in modern standby (e.g. overnight) will almost certainly reproduce this behavior. Most of the time it will also result in VSCode asking for "reload the window" as well (like in #3126).
Therefore, I really hope that you migrate to AF_VSOCK/AF_HYPERV instead. Or perhaps, make this extension open source so I can modify it. 馃榿
Yeah this problem is horrible please escalate. I find myself having to restart vscode 2x to 3x daily because I do all my work in WSL remote and the reload ruins my terminal sessions with running programs. Terrible for programmer productivity.
Also for whatever stupid clearly related reason workplace settings on remote are not honored. So my windows always lose their color scheme (I use a different color scheme for each project). I'll open a second ticket for this issue but mention it because this chore of manually resetting color schemes in 6 windows wouldn't be relevant except for this super weird reload bug.
Please fix it ASAP thanks.
I'd add that once WSL 2 is started, the hns service can be disabled to prevent the Hyper-V virtual switches from disconnecting when the computer enters modern standby. On my Dell XPS 15 9560, disabling this service doesn't seem to prevent the computer from entering DRIPS either.
The only downside is that if we stop the WSL 2 (e.g. by logging off or running wsl --shutdown), it won't be able to start. In that case, to restart WSL 2 without rebooting the computer, we can take the following steps in order:
LxssManager service.hns service.hns service.Had done this in the last 4 days and no more reconnecting / "please reload window" after resuming from modern standby, even when the modern standby lasted overnight. It now works flawlessly as it should. But I have to stress again, this is just a hack, and there should be no reason for VSCode not to use AF_HYPERV/AF_VSOCK.
Also to Hyper-V team (where I can file this to them by the way?), there should be no reason why would you disconnect the virtual switches when the computer enters modern standby. I didn't find any single issue so far, even with regular Hyper-V VMs. Both the default NAT network and bridged networks works flawlessly as well with the hns service disabled after I've started at least one VM that uses the virtual switches.
For me the issue started when I installed 2 extensions on VSCode to the point that VSCode would just work for 2-3 seconds only. After deleting them, it is working so far.
Extensions are:
Most helpful comment
Yeah this problem is horrible please escalate. I find myself having to restart vscode 2x to 3x daily because I do all my work in WSL remote and the reload ruins my terminal sessions with running programs. Terrible for programmer productivity.
Also for whatever stupid clearly related reason workplace settings on remote are not honored. So my windows always lose their color scheme (I use a different color scheme for each project). I'll open a second ticket for this issue but mention it because this chore of manually resetting color schemes in 6 windows wouldn't be relevant except for this super weird reload bug.
Please fix it ASAP thanks.