BoundaryML/baml · error · RuntimeCallbackError
Failed to send cred request across WASM bridge
Error message
Failed to send cred request across WASM bridge: {0} What it means
RuntimeCallbackError::SendError is raised when the tokio mpsc `Sender::send` used to forward an AWS or GCP credential request across the WASM bridge fails. In BAML's WASM runtime, Rust calls into a JS-side credential provider (Smithy AwsCredentialIdentity-compatible) via a channel; a failed send means the receiver side of the bridge is gone, so no credential request can be delivered. The underlying tokio SendError is stringified into the message.
Solutions
- Verify the JS-side credential provider (e.g. `b.setupJsCallbackProvider(...)` / AWS SDK cred provider chain) is registered and kept alive before making BAML calls that need AWS/GCP creds.
- Check that the WASM runtime/worker hosting the bridge receiver has not exited or been disposed; reinitialize the runtime if it has.
- Retry the operation - the bridge may be transiently down during startup; ensure set_js_callback_provider ran before the request.
- Inspect the stringified tokio error in the message to confirm whether the channel was closed (receiver dropped) versus a full/lagged channel.
Example fix
// before: calling BAML function before the JS cred provider bridge is set up
const result = await b.GenerateSummary(input); // Rust: req_tx.send fails (receiver dropped)
// after: initialize the provider bridge first, then call
await b.setupJsCallbackProvider({ awsCredentialProvider: fromIni({ profile: 'my-profile' }) });
const result = await b.GenerateSummary(input); Defensive patterns
Strategy: try-catch
Try / catch
// JS side
try {
const result = await b.GenerateSummary(input);
} catch (e) {
if (String(e).includes('Failed to send cred request across WASM bridge')) {
// bridge receiver dropped: re-initialize provider/runtime, then retry once
await setupCredentialBridge();
return await b.GenerateSummary(input);
}
throw e;
} Prevention
- Register the JS credential provider bridge before any LLM call
- Keep the WASM runtime/worker alive for the duration of in-flight requests
- Avoid disposing or replacing the cred provider mid-request
When it happens
Trigger: JsCallbackProvider::aws_req (js_callback_provider.rs:101-104) or gcp_req (js_callback_provider.rs:124-127) calls `req_tx.send(...)` and the receiving task on the JS/WASM side has been dropped or the channel is closed, returning `Err(e)` which becomes `RuntimeCallbackError::SendError(e.to_string())`.
Common situations: Running BAML inside a Node/browser WASM build where the JS credential-provider task has terminated, the WASM bridge receiver was dropped during shutdown, or the AWS credential chain (e.g. `fromIni(profile)` / default provider) was torn down before an LLM call needed credentials.
Related errors
- Failed to recv cred response across WASM bridge
- AbortError
- BAML engine is shutting down
- Expr function error
- Future with ID not found
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/ebe3529978fc2275.
Report an issue: GitHub.
Appendix: source
Thrown at engine/baml-runtime/src/types/js_callback_provider.rs:26
pub enum JsCallbackResult<T> {
#[serde(rename = "ok")]
Ok(T),
#[serde(rename = "error")]
Err(JsCallbackError),
}
#[derive(Debug, serde::Deserialize, Eq, PartialEq)]
/// Deserialization helper for js_callback_bridge; declared here to enable deserialization unit testing.
pub struct JsCallbackError {
pub name: String,
pub message: String,
}
#[derive(Debug, Error, Clone)]
/// For baml-src-reader and aws-cred-provider, provide a statically defined type which is Send + Sync
/// anyhow::Error is not Send + Sync, so it's convoluted to use it in this callback context
pub enum RuntimeCallbackError {
#[error("Failed to send cred request across WASM bridge: {0}")]
SendError(String),
#[error("Failed to recv cred response across WASM bridge: {0}")]
RecvError(String),
#[error("Type error in JS callback: {0}")]
JsCallbackTypeError(String),
#[error("JS callback error: {name}: {message}")]
JsCallbackRuntimeError { name: String, message: String },
#[error("BAML internal error - credential provider bridges not initialized")]
NoCredProviderBridge,
}
static_assertions::assert_impl_all!(RuntimeCallbackError: Send, Sync);
pub type RuntimeCallbackResult<T> = Result<T, RuntimeCallbackError>;View on GitHub (pinned to bd85ce9dee)