{"record":{"id":"fc52bf07f98775ff","repo":"zed-industries/zed","slug":"app-state-dropped","errorCode":null,"errorMessage":"App state dropped","messagePattern":"App state dropped","errorType":"exception","errorClass":"BedrockError","httpStatus":null,"severity":"error","filePath":"crates/language_models/src/provider/bedrock.rs","lineNumber":809,"sourceCode":"            .context(\"initializing Bedrock client\")?;\n\n        self.client.get().context(\"Bedrock client not initialized\")\n    }\n\n    fn stream_completion(\n        &self,\n        request: bedrock::Request,\n        cx: &AsyncApp,\n    ) -> BoxFuture<\n        'static,\n        Result<BoxStream<'static, Result<BedrockStreamingResponse, anyhow::Error>>, BedrockError>,\n    > {\n        let Ok(runtime_client) = self\n            .get_or_init_client(cx)\n            .cloned()\n            .context(\"Bedrock client not initialized\")\n        else {\n            return futures::future::ready(Err(BedrockError::Other(anyhow!(\"App state dropped\"))))\n                .boxed();\n        };\n        let extra_headers = self.state.read_with(cx, |_, cx| {\n            AllLanguageModelSettings::get_global(cx)\n                .bedrock\n                .custom_headers\n                .clone()\n        });\n\n        let task = Tokio::spawn(\n            cx,\n            bedrock::stream_completion(runtime_client, request, extra_headers),\n        );\n        async move { task.await.map_err(|e| BedrockError::Other(e.into()))? }.boxed()\n    }\n}\n\nimpl LanguageModel for BedrockModel {","sourceCodeStart":791,"sourceCodeEnd":827,"githubUrl":"https://github.com/zed-industries/zed/blob/5a9b9558db01a6b906cec2fb70a797affdc58cdd/crates/language_models/src/provider/bedrock.rs#L791-L827","documentation":"Sentinel error in BedrockLanguageModelProvider::stream_completion: get_or_init_client failed because it could not access the App state via the AsyncApp handle — the App/context handle used to lazily initialize the Bedrock client is no longer valid (the application state was torn down). The provider cannot obtain or build its runtime client, so the completion request fails immediately.","triggerScenarios":"Thrown at crates/language_models/src/provider/bedrock.rs:806 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the provider outlives the request: don't issue Bedrock requests after app/teardown has begun","Hold a strong reference to the required state for the duration of the async request","If seen in tests, keep the TestAppContext/AsyncApp alive while the streaming task runs"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5a9b9558db01a6b906cec2fb70a797affdc58cdd","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}