Skip to content

fix(auth): honor expires_in and bound transient network retries in device login - #28

Merged
duyetbot merged 1 commit into
mainfrom
cursor/device-login-deadline-4630
Aug 28, 2026
Merged

fix(auth): honor expires_in and bound transient network retries in device login#28
duyetbot merged 1 commit into
mainfrom
cursor/device-login-deadline-4630

Conversation

@duyet

@duyet duyet commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Device login parsed expires_in but the poll loop never used it, and transport errors retried forever (anyr relay start auto-login hits the same loop). This change extracts a pure poll_action helper and rewrites poll_device_token to:

  • Give up when wall-clock elapsed time reaches expires_in (floored at 60s)
  • Give up after 5 consecutive transport errors
  • Keep sleeping before each attempt (no busy-wait)
  • Leave poll_device_token / login_via_device public signatures unchanged

Only src/auth.rs is modified. No new crates.

Closes #18

Checklist

  • Version stays on 0.1.x (do not introduce 0.2 / 1.0)
  • Do not auto-merge release-please PRs

Skip co-authors

  • I skipped co-author trailers on purpose
Open in Web Open in Cursor 

…vice login

Device login parsed expires_in but the poll loop never used it, and
transport errors retried forever. Drive the loop from a pure poll_action
helper so wall-clock expiry and five consecutive network failures give up.

Closes #18

Co-authored-by: duyet <duyet@users.noreply.github.com>
@duyet
duyet marked this pull request as ready for review August 28, 2026 04:34
@github-actions

Copy link
Copy Markdown
Contributor

anyr size and startup

Startup is wall time for a cold anyr --version / anyr --help (median of 21 runs). Size is the stripped release binary, or the .wasm for the browser demo.

Size budget: anyr-linux-x86_64 must stay ≤ 4.0 MiB (4194304 bytes) stripped.

Asset Kind Size --version median --help median
anyr-darwin-arm64 native 2.7 MiB 2.61 ms 2.33 ms
anyr-darwin-x86_64 native 2.9 MiB 30.34 ms 28.92 ms
anyr-linux-arm64 native 2.6 MiB 0.64 ms 0.65 ms
anyr-linux-x86_64 native 3.0 MiB 1.09 ms 1.05 ms
anyr-windows-x86_64.exe native 2.5 MiB 9.21 ms 9.24 ms
anyr.wasm wasm 175.1 KiB

Budget check: ok

raw timings
[
  {
    "asset": "anyr-darwin-arm64",
    "kind": "native",
    "path": "/Users/runner/work/cli/cli/anyr-darwin-arm64",
    "bytes": 2803480,
    "size": "2.7 MiB",
    "version": "0.1.11 (built 2026-08-28 04:35:18)",
    "target": "aarch64-apple-darwin",
    "os": "macos-latest",
    "startup_version": {
      "n": 21,
      "min_ms": 2.54,
      "median_ms": 2.61,
      "p95_ms": 2.83,
      "mean_ms": 2.67
    },
    "startup_help": {
      "n": 21,
      "min_ms": 2.3,
      "median_ms": 2.33,
      "p95_ms": 2.59,
      "mean_ms": 2.37
    }
  },
  {
    "asset": "anyr-darwin-x86_64",
    "kind": "native",
    "path": "/Users/runner/work/cli/cli/anyr-darwin-x86_64",
    "bytes": 3014656,
    "size": "2.9 MiB",
    "version": "0.1.11 (built 2026-08-28 04:35:32)",
    "target": "x86_64-apple-darwin",
    "os": "macos-latest",
    "startup_version": {
      "n": 21,
      "min_ms": 29.55,
      "median_ms": 30.34,
      "p95_ms": 35.95,
      "mean_ms": 31.75
    },
    "startup_help": {
      "n": 21,
      "min_ms": 28.42,
      "median_ms": 28.92,
      "p95_ms": 29.71,
      "mean_ms": 29.04
    }
  },
  {
    "asset": "anyr-linux-arm64",
    "kind": "native",
    "path": "/home/runner/work/cli/cli/anyr-linux-arm64",
    "bytes": 2757672,
    "size": "2.6 MiB",
    "version": "0.1.11 (built 2026-08-28 04:35:02)",
    "target": "aarch64-unknown-linux-gnu",
    "os": "ubuntu-24.04-arm",
    "startup_version": {
      "n": 21,
      "min_ms": 0.61,
      "median_ms": 0.64,
      "p95_ms": 0.82,
      "mean_ms": 0.66
    },
    "startup_help": {
      "n": 21,
      "min_ms": 0.61,
      "median_ms": 0.65,
      "p95_ms": 0.68,
      "mean_ms": 0.65
    }
  },
  {
    "asset": "anyr-linux-x86_64",
    "kind": "native",
    "path": "/home/runner/work/cli/cli/anyr-linux-x86_64",
    "bytes": 3111144,
    "size": "3.0 MiB",
    "version": "0.1.11 (built 2026-08-28 04:35:18)",
    "target": "x86_64-unknown-linux-gnu",
    "os": "ubuntu-latest",
    "startup_version": {
      "n": 21,
      "min_ms": 1.04,
      "median_ms": 1.09,
      "p95_ms": 1.13,
      "mean_ms": 1.09
    },
    "startup_help": {
      "n": 21,
      "min_ms": 1.02,
      "median_ms": 1.05,
      "p95_ms": 1.12,
      "mean_ms": 1.06
    }
  },
  {
    "asset": "anyr-windows-x86_64.exe",
    "kind": "native",
    "path": "D:\\a\\cli\\cli\\anyr-windows-x86_64.exe",
    "bytes": 2577408,
    "size": "2.5 MiB",
    "version": "0.1.11 (built 2026-08-28T04:36:21Z)",
    "target": "x86_64-pc-windows-msvc",
    "os": "windows-latest",
    "startup_version": {
      "n": 21,
      "min_ms": 9.0,
      "median_ms": 9.21,
      "p95_ms": 9.9,
      "mean_ms": 9.34
    },
    "startup_help": {
      "n": 21,
      "min_ms": 9.03,
      "median_ms": 9.24,
      "p95_ms": 9.41,
      "mean_ms": 9.24
    }
  },
  {
    "asset": "anyr.wasm",
    "kind": "wasm",
    "path": "/home/runner/work/cli/cli/target/wasm-pkg/anyr_cli_bg.wasm",
    "bytes": 179312,
    "size": "175.1 KiB",
    "version": "wasm",
    "target": "wasm32-unknown-unknown",
    "os": ""
  }
]

@duyetbot
duyetbot merged commit 689b54f into main Aug 28, 2026
9 checks passed
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 this pull request may close these issues.

Plan 003: Give device-code login a deadline and a bounded network retry

3 participants