{"record":{"id":"549a46c98d628193","repo":"pbakaus/impeccable","slug":"authentication-failed-the-server-token-may-have-c","errorCode":null,"errorMessage":"Authentication failed. The server token may have changed.\n","messagePattern":"Authentication failed\\. The server token may have changed\\.\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/live/src/live_poll.rs","lineNumber":638,"sourceCode":"        .map(|t| EVENT_TYPES_NEEDING_AGENT_REPLY.contains(&t))\n        .unwrap_or(false)\n}\n\nfn handle_event(mut event: Value, base: &str, token: &str, io: &mut Io) -> Value {\n    if let Value::Object(obj) = &mut event {\n        augment_event_with_accept_handling(obj, base, token, io);\n        write_carbonize_banner(obj, io);\n    }\n    print_poll_event(&mut event, io);\n    event\n}\n\nfn handle_poll_error(err: PollError, io: &mut Io) -> i32 {\n    let cwd = io.cwd.to_string_lossy().into_owned();\n    let env = io.env.clone();\n    match err {\n        PollError::Auth => {\n            io.err(\"Authentication failed. The server token may have changed.\\n\");\n            io.err(&format!(\n                \"Try restarting: {} stop && {}\\n\",\n                script_cmd(&env, &cwd, \"live-server\"),\n                script_cmd(&env, &cwd, \"live\")\n            ));\n            1\n        }\n        PollError::ConnRefused => {\n            io.err(&format!(\n                \"Live server not running. Start one with: {}\\n\",\n                script_cmd(&env, &cwd, \"live\")\n            ));\n            1\n        }\n        PollError::AckTimeout(m) => {\n            io.err(&format!(\"{}\\n\", m));\n            1\n        }","sourceCodeStart":620,"sourceCodeEnd":656,"githubUrl":"https://github.com/pbakaus/impeccable/blob/2bc2879276c1f321a53c4ca99d3371e411329b52/crates/live/src/live_poll.rs#L620-L656","documentation":"handle_poll_error maps PollError::Auth to this message and exits with code 1 when the live poller's authentication with the local live server fails. The server token rotates or is regenerated on restart, so an old polling client is rejected.","triggerScenarios":"The `live` poll loop receives PollError::Auth — typically because the token persisted by the client no longer matches the live-server's current token after the server restarted or was reinitialized.","commonSituations":"Live server restarted while a stale poller/agent session kept the old token; multiple projects sharing state; manually editing or deleting the token/state file.","solutions":["Restart both processes as the message suggests: run `<live-server> stop` then `<live>` again so the client picks up the fresh token.","Confirm the token/state files for this project match the running server's token.","Ensure only one live-server instance per project is running (duplicate instances can rotate tokens)."],"exampleFix":"// before\n$ impeccable live  # poll with stale token\nAuthentication failed. The server token may have changed.\n// after\n$ impeccable live-server stop && impeccable live","handlingStrategy":"retry","validationCode":"// Compare client token with the server's current token before polling\nconst clientToken = readStateToken();\nconst serverToken = readServerToken();\nif (clientToken !== serverToken) console.error('token mismatch: restart live-server && live');","typeGuard":null,"tryCatchPattern":"match poll_once(&session) {\n  Err(PollError::Auth) => { restart_live_session(); retry(); }\n  Err(other) => handle_poll_error(other, io),\n  Ok(v) => v,\n}","preventionTips":["Restart the poller together with the server (`live-server stop && live`) rather than reusing long-lived sessions.","Never hand-edit or copy token state files between projects.","Run one live-server per project to avoid token rotation races."],"tags":["authentication","token","live-server","cli"],"backgroundTag":"authentication-required","analyzedSha":"2bc2879276c1f321a53c4ca99d3371e411329b52","analyzedAt":"2026-09-08T04:51:14.109Z","contentChangedAt":"2026-09-08T04:51:14.109Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}