zed-industries/zed · error · BedrockError

App state dropped

Error message

App state dropped

What it means

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.

Source

Thrown at crates/language_models/src/provider/bedrock.rs:809

            .context("initializing Bedrock client")?;

        self.client.get().context("Bedrock client not initialized")
    }

    fn stream_completion(
        &self,
        request: bedrock::Request,
        cx: &AsyncApp,
    ) -> BoxFuture<
        'static,
        Result<BoxStream<'static, Result<BedrockStreamingResponse, anyhow::Error>>, BedrockError>,
    > {
        let Ok(runtime_client) = self
            .get_or_init_client(cx)
            .cloned()
            .context("Bedrock client not initialized")
        else {
            return futures::future::ready(Err(BedrockError::Other(anyhow!("App state dropped"))))
                .boxed();
        };
        let extra_headers = self.state.read_with(cx, |_, cx| {
            AllLanguageModelSettings::get_global(cx)
                .bedrock
                .custom_headers
                .clone()
        });

        let task = Tokio::spawn(
            cx,
            bedrock::stream_completion(runtime_client, request, extra_headers),
        );
        async move { task.await.map_err(|e| BedrockError::Other(e.into()))? }.boxed()
    }
}

impl LanguageModel for BedrockModel {

View on GitHub (pinned to 5a9b9558db)

Solutions

  1. Ensure the provider outlives the request: don't issue Bedrock requests after app/teardown has begun
  2. Hold a strong reference to the required state for the duration of the async request
  3. If seen in tests, keep the TestAppContext/AsyncApp alive while the streaming task runs
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at crates/language_models/src/provider/bedrock.rs:806 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@5a9b9558db (2026-08-20). Data as JSON: /api/errors/fc52bf07f98775ff. Report an issue: GitHub.