Skip to content

Initial coordination dial in Coder Desktop should fail fast #18599

Description

@ethanndickson

Currently, the first time Coder Desktop dials /api/v2/tailnet is within the main Controller.Run loop:

tailnetClients, err := c.Dialer.Dial(c.ctx, c.ResumeTokenCtrl)

This means the tunnel sends the StartResponse with success set to true without knowing whether or not it was able to dial the coordination endpoint. This results in a poor UX if we're not able to dial it initially; Coder Connect appears functional but is not - the only sign something went wrong is the No workspaces message, and N error logs, for each retry attempt.

Instead, we should fail fast, and send a StartResponse with success set to false if we fail to dial right after starting.

Activity

  1. added theissue type on Jun 30, 2025
  2. added
    desktop
    on Jun 30, 2025
  3. ethanndickson commented on Aug 5, 2025

    @ethanndickson
    MemberAuthor

    Looking into this, we do actually fail-fast:

    if w.isFirst {
    if res != nil && slices.Contains(permanentErrorStatuses, res.StatusCode) {
    err = codersdk.ReadBodyAsError(res)
    // A bit more human-readable help in the case the API version was rejected
    var sdkErr *codersdk.Error
    if xerrors.As(err, &sdkErr) {
    if sdkErr.Message == AgentAPIMismatchMessage &&
    sdkErr.StatusCode() == http.StatusBadRequest {
    sdkErr.Helper = fmt.Sprintf(
    "Ensure your client release version (%s, different than the API version) matches the server release version",
    buildinfo.Version())
    }
    if sdkErr.Message == codersdk.DatabaseNotReachable &&
    sdkErr.StatusCode() == http.StatusInternalServerError {
    err = xerrors.Errorf("%w: %v", codersdk.ErrDatabaseNotReachable, err)
    }
    }
    w.connected <- err
    return tailnet.ControlProtocolClients{}, err
    }
    w.isFirst = false
    close(w.connected)
    }

    However, in the incident that prompted the creation of this issue there was a client-side bug that resulted in:

    • All the preceding requests authenticating fine (namely /users/me)
    • The dial failing to authenticate

    Since a 401 isn't in the list of permanent error statuses, w.connected gets closed, and the dialer marked as 'connected', even though it failed.

  4. added a commit that references this issue on Aug 5, 2025
    8b66a5a
  5. self-assigned this
    on Aug 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

desktop

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions