{"record":{"id":"a7012688b03b8cbc","repo":"Hmbown/CodeWhale","slug":"turn-canceled","errorCode":null,"errorMessage":"turn canceled","messagePattern":"turn canceled","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"info","filePath":"crates/app-server/src/lib.rs","lineNumber":1892,"sourceCode":"                \"thread\": Value::Null,\n                \"threads\": [],\n                \"model\": Value::Null,\n                \"model_provider\": Value::Null,\n                \"cwd\": Value::Null,\n                \"approval_policy\": Value::Null,\n                \"sandbox\": Value::Null,\n                \"events\": [],\n                \"data\": { \"turn_id\": turn_id },\n            })),\n            TurnTerminalStatus::Failed => Err(anyhow!(\n                \"{}\",\n                error.unwrap_or_else(|| \"turn failed\".to_string())\n            )),\n            TurnTerminalStatus::Interrupted => Err(anyhow!(\n                \"{}\",\n                error.unwrap_or_else(|| \"turn interrupted\".to_string())\n            )),\n            TurnTerminalStatus::Canceled => Err(anyhow!(\n                \"{}\",\n                error.unwrap_or_else(|| \"turn canceled\".to_string())\n            )),\n        }\n    }\n\n    async fn stream_turn_events<W: AsyncWrite + Unpin>(\n        &self,\n        thread_id: &str,\n        turn_id: &str,\n        response_id: &str,\n        writer: &mut W,\n        since_seq: u64,\n        mut transcript: Option<&mut TurnTranscript>,\n    ) -> Result<(u64, TurnTerminalStatus, Option<String>)> {\n        let mut response = self\n            .authed(self.client.get(format!(\n                \"{}/v1/threads/{thread_id}/events?since_seq={since_seq}\",","sourceCodeStart":1874,"sourceCodeEnd":1910,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/app-server/src/lib.rs#L1874-L1910","documentation":"Raised when a runtime API turn reaches `TurnTerminalStatus::Canceled`. Like the failed/interrupted branches, it converts the terminal event to an error, using the event's error message if present or the literal \"turn canceled\" fallback. Canceled is distinct from interrupted: the turn was explicitly cancelled before completing.","triggerScenarios":"A turn's event stream reports the Canceled terminal status — an explicit cancellation of the turn on the runtime side.","commonSituations":"Caller aborts the request (dropped future, ctrl-c, client disconnect); an upper layer cancels the runtime session; a cleanup/shutdown path cancelling in-flight turns.","solutions":["If cancellation was intentional, handle this status gracefully in the caller instead of logging it as a failure.","If not intentional, check for request timeouts or dropped connections between the client and the runtime.","Inspect session logs to identify which component issued the cancel.","Re-run the turn if the work was cancelled prematurely."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match run_turn(...).await {\n    Err(e) if e.to_string().contains(\"turn canceled\") => { /* expected during shutdown/abort */ }\n    other => other?,\n}","preventionTips":["Track which component issues cancellations","Handle Canceled as a normal shutdown outcome","Avoid dropping the turn future unless cancellation is intended"],"tags":["turn","canceled","runtime-api"],"backgroundTag":"operation-canceled","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}