{"record":{"id":"883a7b68bed63c3f","repo":"Kuberwastaken/claurst","slug":"callback-server-dropped","errorCode":null,"errorMessage":"Callback server dropped","messagePattern":"Callback server dropped","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-rust/crates/cli/src/oauth_flow.rs","lineNumber":531,"sourceCode":"        let _ = cb_tx.send(result);\r\n    });\r\n\r\n    let (paste_tx, paste_rx) = tokio::sync::oneshot::channel::<String>();\r\n    tokio::spawn(async move {\r\n        if let Ok(line) = read_line_from_stdin().await {\r\n            let trimmed = line.trim().to_string();\r\n            if !trimmed.is_empty() {\r\n                let _ = paste_tx.send(trimmed);\r\n            }\r\n        }\r\n    });\r\n\r\n    tokio::select! {\r\n        result = cb_rx => {\r\n            // Loopback callback: code came clean from the query string and was\r\n            // authorized against the localhost redirect_uri.\r\n            result\r\n                .unwrap_or_else(|_| Err(anyhow::anyhow!(\"Callback server dropped\")))\r\n                .map(|code| (code, false))\r\n        }\r\n        code = paste_rx => {\r\n            // Manual paste: the page hands back \"<code>#<state>\"; keep only the\r\n            // code part. This path authorized against MANUAL_REDIRECT_URL.\r\n            let raw = code.map_err(|_| anyhow::anyhow!(\"Stdin closed unexpectedly\"))?;\r\n            let code_only = raw.split('#').next().unwrap_or(&raw).trim().to_string();\r\n            Ok((code_only, true))\r\n        }\r\n        _ = tokio::time::sleep(Duration::from_secs(120)) => {\r\n            bail!(\"Authentication timed out after 120 seconds\")\r\n        }\r\n    }\r\n}\r\n","sourceCodeStart":513,"sourceCodeEnd":546,"githubUrl":"https://github.com/Kuberwastaken/claurst/blob/b0637c97ec34144387cbf2f74f65df6d16a6cef1/src-rust/crates/cli/src/oauth_flow.rs#L513-L546","documentation":"In wait_for_auth_code_impl, the mpsc receiver for the loopback callback server yielded None, meaning the callback server task terminated without sending an authorization code. The unwrap_or_else converts that channel closure into this error. Normal result delivery would have carried either a code or the server's own error.","triggerScenarios":"tokio::select! branch `result = cb_rx` receives Err (channel closed) instead of a message: the local HTTP callback server task in run_oauth_login_flow_with_label panicked, was dropped, or shut down before the browser hit the redirect.","commonSituations":"Port conflict killing the loopback server at startup; another agent/process killing the task; a panic inside the callback handler; OS firewall or sandbox terminating the listener.","solutions":["Re-run the OAuth login flow; this is usually a one-off task failure.","Check that the loopback redirect port is free and not blocked by a firewall.","Use the manual paste path (paste the auth code into stdin) if the callback server cannot bind.","Check application logs for a panic in the callback server task."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// ensure the callback port is bindable before starting the server\nTcpListener::bind((\"127.0.0.1\", port)).await\n    .map_err(|e| anyhow!(\"callback port {} unavailable: {}\", port, e))?;","typeGuard":null,"tryCatchPattern":"// fall back to manual paste when the callback channel dies\ntokio::select! {\n    result = cb_rx => result.unwrap_or_else(|_| Err(anyhow!(\"Callback server dropped\"))),\n    _ = prompt_manual_paste() => prompt_manual_paste().await,\n}","preventionTips":["Check the loopback port is free and not blocked by a firewall before starting login","Keep a manual paste fallback path ready","Monitor the callback task and log panics so drops are diagnosable"],"tags":["oauth","callback","tokio","channel"],"backgroundTag":"oauth-callback-server-dropped","analyzedSha":"b0637c97ec34144387cbf2f74f65df6d16a6cef1","analyzedAt":"2026-09-10T00:24:58.650Z","contentChangedAt":"2026-09-10T00:24:58.650Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}