{"record":{"id":"ebe3529978fc2275","repo":"BoundaryML/baml","slug":"failed-to-send-cred-request-across-wasm-bridge-0","errorCode":null,"errorMessage":"Failed to send cred request across WASM bridge: {0}","messagePattern":"Failed to send cred request across WASM bridge: (.+?)","errorType":"exception","errorClass":"RuntimeCallbackError","httpStatus":null,"severity":"error","filePath":"engine/baml-runtime/src/types/js_callback_provider.rs","lineNumber":26,"sourceCode":"pub enum JsCallbackResult<T> {\n    #[serde(rename = \"ok\")]\n    Ok(T),\n    #[serde(rename = \"error\")]\n    Err(JsCallbackError),\n}\n\n#[derive(Debug, serde::Deserialize, Eq, PartialEq)]\n/// Deserialization helper for js_callback_bridge; declared here to enable deserialization unit testing.\npub struct JsCallbackError {\n    pub name: String,\n    pub message: String,\n}\n\n#[derive(Debug, Error, Clone)]\n/// For baml-src-reader and aws-cred-provider, provide a statically defined type which is Send + Sync\n/// anyhow::Error is not Send + Sync, so it's convoluted to use it in this callback context\npub enum RuntimeCallbackError {\n    #[error(\"Failed to send cred request across WASM bridge: {0}\")]\n    SendError(String),\n\n    #[error(\"Failed to recv cred response across WASM bridge: {0}\")]\n    RecvError(String),\n\n    #[error(\"Type error in JS callback: {0}\")]\n    JsCallbackTypeError(String),\n\n    #[error(\"JS callback error: {name}: {message}\")]\n    JsCallbackRuntimeError { name: String, message: String },\n\n    #[error(\"BAML internal error - credential provider bridges not initialized\")]\n    NoCredProviderBridge,\n}\n\nstatic_assertions::assert_impl_all!(RuntimeCallbackError: Send, Sync);\n\npub type RuntimeCallbackResult<T> = Result<T, RuntimeCallbackError>;","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-runtime/src/types/js_callback_provider.rs#L8-L44","documentation":"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.","triggerScenarios":"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())`.","commonSituations":"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.","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."],"exampleFix":"// before: calling BAML function before the JS cred provider bridge is set up\nconst result = await b.GenerateSummary(input); // Rust: req_tx.send fails (receiver dropped)\n\n// after: initialize the provider bridge first, then call\nawait b.setupJsCallbackProvider({ awsCredentialProvider: fromIni({ profile: 'my-profile' }) });\nconst result = await b.GenerateSummary(input);","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// JS side\ntry {\n  const result = await b.GenerateSummary(input);\n} catch (e) {\n  if (String(e).includes('Failed to send cred request across WASM bridge')) {\n    // bridge receiver dropped: re-initialize provider/runtime, then retry once\n    await setupCredentialBridge();\n    return await b.GenerateSummary(input);\n  }\n  throw e;\n}","preventionTips":["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"],"tags":["wasm","aws-credentials","channel","async","rust"],"backgroundTag":"missing-credentials","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}