nanocoder
nanocoder copied to clipboard
[Bug] Copilot login fails on `slow_down` instead of polling more slowly
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
- Call
runCopilotLoginFlow('verify-copilot', {onShowCode, fetchFn})with afetchFnthat 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 fordata.error === 'slow_down'next toauthorization_pending(line 143). IncreaseintervalMsby 5000 (RFC 8628), or usedata.intervalif present, and continue.- Add a test like the steps above.
I'll take this one. The repro from the issue is clear and the fix looks small (a slow_down branch in pollForOAuthToken).