nanocoder icon indicating copy to clipboard operation
nanocoder copied to clipboard

[Bug] Copilot login fails on `slow_down` instead of polling more slowly

Open addyCooks opened this issue 1 week ago • 1 comments

Description

The GitHub device flow can answer a poll with slow_down, which means "wait longer between polls". Nanocoder treats it like an error, so /login copilot fails with "Authorization failed: slow_down" while the user is still allowed to finish.

Environment

  • OS: Windows 11 Home 10.0.26300
  • Node version: v22.22.3
  • Nanocoder version: 1.32.0 (built from main at eb7dee57)
  • Provider: GitHub Copilot (fake backend)
  • Model: Not model-specific

Steps to Reproduce

  1. Call runCopilotLoginFlow('verify-copilot', {onShowCode, fetchFn}) with a fetchFn that returns: first the device code (interval: 1), then {"error":"slow_down","interval":10}, then {"access_token":"gho_token"}.

Expected Behavior

The flow waits longer (add 5 seconds, or use the new interval), then the third request succeeds and the credential is saved.

Actual Behavior

The login rejects on the second request.

Logs/Screenshots

Authorization failed: slow_down

Additional Context

  • [x] I have searched existing issues to ensure this is not a duplicate
  • [x] I can reproduce this issue consistently
  • [x] This issue occurs with the latest version of nanocoder (main)

Suggested fix:

  • source/auth/github-copilot.ts:98-153 (pollForOAuthToken): add a branch for data.error === 'slow_down' next to authorization_pending (line 143). Increase intervalMs by 5000 (RFC 8628), or use data.interval if present, and continue.
  • Add a test like the steps above.

addyCooks avatar Nov 23 '26 07:11 addyCooks

I'll take this one. The repro from the issue is clear and the fix looks small (a slow_down branch in pollForOAuthToken).

MaxonT avatar Nov 23 '26 08:11 MaxonT