{"record":{"id":"3f9ee1f257c78180","repo":"astral-sh/uv","slug":"login-session-timed-out-after-status-retry-limit","errorCode":null,"errorMessage":"Login session timed out after {STATUS_RETRY_LIMIT} seconds","messagePattern":"Login session timed out after (.+?) seconds","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/uv/src/commands/auth/login.rs","lineNumber":238,"sourceCode":"        match response.status() {\n            // Retry on 404.\n            reqwest::StatusCode::NOT_FOUND => {\n                tokio::time::sleep(std::time::Duration::from_secs(1)).await;\n                retry += 1;\n            }\n            // Parse the credentials on success.\n            _ if response.status().is_success() => {\n                let credentials = response.json::<PyxOAuthTokens>().await?;\n                break Ok::<PyxTokens, anyhow::Error>(PyxTokens::OAuth(credentials));\n            }\n            // Fail on any other status code (like a 500).\n            status => {\n                break Err(anyhow::anyhow!(\"Failed to login with code `{status}`\"));\n            }\n        }\n\n        if retry >= STATUS_RETRY_LIMIT {\n            break Err(anyhow::anyhow!(\n                \"Login session timed out after {STATUS_RETRY_LIMIT} seconds\"\n            ));\n        }\n    }?;\n\n    store.write(&credentials).await?;\n\n    Ok(AccessToken::from(credentials))\n}\n","sourceCodeStart":220,"sourceCodeEnd":248,"githubUrl":"https://github.com/astral-sh/uv/blob/f1a42680ff5272232d65748acf338b19778dde24/crates/uv/src/commands/auth/login.rs#L220-L248","documentation":"The pyx browser login flow polls the status endpoint once per second and allows at most STATUS_RETRY_LIMIT (60) consecutive 404s before giving up with this timeout message. It means the login code was never completed in the browser within 60 seconds, so no OAuth tokens were ever returned.","triggerScenarios":"Running `uv login` on a headless machine (CI container, SSH session) where `open::that` could not launch a browser or the user never visited the printed URL; starting login and getting distracted for over a minute; browser opened to the login URL but the user did not approve within 60 seconds.","commonSituations":"CI/automation scripts invoking `uv login` with no interactive browser; SSH into a remote box where xdg-open has no handler; slow SSO portal that takes longer than a minute to complete.","solutions":["Run `uv login` where a browser is available, copy the printed URL into a local browser if the remote box cannot open one, and finish authentication within 60 seconds.","For headless/CI environments, avoid browser login entirely: use a pre-provisioned token (e.g., `uv login --token` or a keyring/text-store credential) instead.","If SSO is slow, complete the identity-provider step in another tab first (warm session), then run `uv login` so approval is a single click inside the window.","Simply re-run the command — each attempt generates a fresh login code."],"exampleFix":"# before (headless CI)\nuv login  # -> Login session timed out after 60 seconds\n# after\nUV_PYX_TOKEN=... uv sync  # or: uv login --token $PYX_TOKEN","handlingStrategy":"retry","validationCode":"# Shell: guard headless environments before attempting browser login\nif [ -z \"${DISPLAY:-}\" ] && [ -z \"${WAYLAND_DISPLAY:-}\" ] && [ ! -t 0 ]; then\n  echo \"no browser available; use: uv login --token $PYX_TOKEN\" >&2\n  exit 1\nfi\nuv login","typeGuard":null,"tryCatchPattern":"match pyx_login_with_browser(&store, &client, &printer).await {\n    Ok(token) => Ok(token),\n    Err(err) if err.to_string().contains(\"timed out\") => {\n        // user simply didn't finish in 60s: one immediate retry with a fresh code\n        pyx_login_with_browser(&store, &client, &printer).await\n    }\n    Err(err) => Err(err),\n}","preventionTips":["On headless machines, authenticate with a token instead of the browser flow.","Copy the printed login URL to a local browser immediately; the code expires after 60 polls.","Pre-warm SSO sessions so the approval step is a single click inside the window."],"tags":["auth","login","timeout","headless"],"backgroundTag":null,"analyzedSha":"f1a42680ff5272232d65748acf338b19778dde24","analyzedAt":"2026-08-16T04:51:47.599Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}