Skip to content

Further improve device wake & sleep handling #88

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ethanndickson opened this issue Mar 4, 2025 · 0 comments · Fixed by #151
Closed

Further improve device wake & sleep handling #88

ethanndickson opened this issue Mar 4, 2025 · 0 comments · Fixed by #151

Comments

@ethanndickson
Copy link
Member

ethanndickson commented Mar 4, 2025

For context, Coder Desktop's networking starts & stops itself on device wake & sleep, respectively. Both of these events can be sent by the operating system even when the device lid is closed, or when the screen is completely off, in order to check for network events.

There's two problems with this right now:

  1. The procedure on wake sets the system VPN state to reasserting. The operating system does not wait for a reasserting state to end before it calls sleep.
    We currently do not handle any form of queuing for these events, so if the tunnel is still starting up, the sleep call is effectively ignored.
    This makes it possible for the VPN to be enabled when the last call from the operating system was sleep. It's not super clear what issues this causes, if any, but it's something we should fix.

  2. A new coder-vpn.dylib can be downloaded, even if the user is not present to enter their password & un-quarantine it.
    If this happens, the networking functionality will fail with an error, and the developer will have to toggle it in settings once again.
    Ideally, this shouldn't happen. Users should be able to wake their laptop from sleep, and CoderVPN should be in (or entering) the same state they left it.
    We should either find a way to recover from this error (by using the previously downloaded coder-vpn.dylib), or simply not start the download if the tunnel was started by a call to wake, where the user might not be present.

ethanndickson added a commit that referenced this issue May 8, 2025
Closes #88.

With coder/internal#563 resolved, there's no need to stop the VPN on sleep, as when the device wakes the tunnel will have the correct workspace & agent state.

However, if the Coder deployment doesn't include the patch in coder/coder#17598 (presumably v2.23 or later), the UI state will go out of sync when the device is slept or internet connection is lost. I think this is fine honestly, and I don't think it's worth doing a server version check to determine whether we should stop the VPN on sleep.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant