Skip to content

Send CoderVPN WakeRequest on system wake to recover tunnel paths #260

Closed

Description

@EhabY

Summary

After macOS sleep/wake, the Coder Connect tunnel can stay unusable for several minutes: new SSH dials fail with i/o timeout until magicsock's periodic re-STUN re-homes the path on its own. macOS wake from a short, same-network sleep often produces no netmon link-change event, so the daemon's existing linkChange() recovery (Rebind + ReSTUN) never fires.

Background

coder/coder PR coder/coder#26739 adds the daemon-side hook for this. It introduces a new CoderVPN RPC (WakeRequest / WakeResponse, tunnel protocol 1.3) whose handler calls tailnet.Conn.Rebind() (magicConn.Rebind() + magicConn.ReSTUN("wake")), the same recovery path a major link change triggers.

The daemon side only exposes the hook. Coder Desktop must actually emit it.

What's needed in coder-desktop-macos

  1. Subscribe to a system wake event, NSWorkspace.shared.notificationCenter didWakeNotification (or IORegisterForSystemPower for lower-level power events).
  2. On wake, send a ManagerMessage with the new WakeRequest over the existing CoderVPN tunnel RPC channel.
  3. Only send when the negotiated tunnel protocol version is >= 1.3 (older daemons won't handle the message). Regenerate the Swift protobuf bindings from the updated vpn.proto once the coder/coder PR merges.
  4. Optionally surface WakeResponse.success / error_message in debug logs.

This is an event-driven kick on a known OS event, not a health check or poll. It forces path re-discovery and never tears down a live tunnel.

Refs

Activity

  1. linear-code commented on Jun 26, 2026

    @linear-code
  2. self-assigned this
    on Jun 26, 2026
  3. ethanndickson commented on Jun 27, 2026

    @ethanndickson
    Member

    Upstream issue for reference: tailscale/tailscale#1554

  4. ethanndickson commented on Jun 29, 2026

    @ethanndickson
    Member

    We should use a system notification that does not trigger on DarkWake, i.e. NSWorkspaceDidWakeNotification or something like that if not available:

    The reason "kIOMessageSystemHasPoweredOn" wasn't delivered is because Dark Wake isn't considered "On". At a higher level, "NSWorkspaceDidWakeNotification" (LaunchAgent only) basically means exactly what you're asking for- the system is "fully awake" and apps should operate normally.

    From https://developer.apple.com/forums/thread/770517

    I can personally verify what the Tailscale issue claims, that NEProvider.sleep and NEProvider.wake trigger on darkwake.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions