{"record":{"id":"4264245dd1b1c0e2","repo":"zed-industries/zed","slug":"session-was-closed-before-load-completed","errorCode":null,"errorMessage":"session was closed before load completed","messagePattern":"session was closed before load completed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/agent_servers/src/acp.rs","lineNumber":1308,"sourceCode":"                                this.sessions.borrow_mut().remove(&session_id);\n                                this.pending_sessions.borrow_mut().remove(&session_id);\n                                return Err(Arc::new(err));\n                            }\n                        };\n\n                    let (modes, config_options) =\n                        config_state(response.modes, response.config_options);\n\n                    if let Some(config_opts) = config_options.as_ref() {\n                        this.apply_default_config_options(&session_id, config_opts, cx);\n                    }\n\n                    this.pending_sessions.borrow_mut().remove(&session_id);\n\n                    {\n                        let mut sessions = this.sessions.borrow_mut();\n                        let Some(session) = sessions.get_mut(&session_id) else {\n                            return Err(Arc::new(anyhow!(\n                                \"session was closed before load completed\"\n                            )));\n                        };\n                        session.session_modes = modes;\n                        session.config_options = config_options.map(ConfigOptions::new);\n                    }\n\n                    Ok(thread)\n                }\n            })\n            .shared();\n\n        self.pending_sessions.borrow_mut().insert(\n            session_id,\n            PendingAcpSession {\n                task: shared_task.clone(),\n            },\n        );","sourceCodeStart":1290,"sourceCodeEnd":1326,"githubUrl":"https://github.com/zed-industries/zed/blob/916fc2b8cb3a815cbef4a3b40e13081be72036b6/crates/agent_servers/src/acp.rs#L1290-L1326","documentation":"During ACP session load, close_session completed while the load RPC was still in flight (the pending_sessions entry was removed / refcount dropped), so the load is aborted because the session no longer exists.","triggerScenarios":"Thrown at crates/agent_servers/src/acp.rs:1277 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Avoid closing the session while its initial load RPC is still in flight","Retry loading or resuming the session after the close completes","Wait for the session to finish loading before issuing close_session"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"916fc2b8cb3a815cbef4a3b40e13081be72036b6","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}