BoundaryML/baml · error
failed to create base http client for WASM: {}
Error message
failed to create base http client for WASM: {} What it means
The WASM variant of the AWS custom HTTP client construction wraps create_client() failures with this message. In browser/WASM builds, reqwest client creation (including proxy handling) failed, so the AWS BAML client cannot be created.
Source
Thrown at engine/baml-runtime/src/internal/llm_client/primitive/aws/custom_http_client.rs:34
// --- WASM specific imports ---
#[cfg(target_arch = "wasm32")]
use {futures::channel::oneshot, wasm_bindgen_futures::spawn_local};
use crate::request::create_client;
/// Returns a wrapper around the global reqwest client.
/// [HttpClient].
#[cfg(not(target_arch = "wasm32"))] // Keep function non-WASM for now
pub fn client() -> anyhow::Result<Client> {
let client = crate::request::create_client()
.map_err(|e| anyhow::anyhow!("failed to create base http client: {}", e))?;
Ok(Client::new(client.clone()))
}
#[cfg(target_arch = "wasm32")] // Define WASM client function
pub fn client() -> anyhow::Result<Client> {
let client = crate::request::create_client()
.map_err(|e| anyhow::anyhow!("failed to create base http client for WASM: {}", e))?;
Ok(Client::new(client.clone()))
}
/// A wrapper around [reqwest::Client] that implements [HttpClient].
///
/// This is required to support using proxy servers with the AWS SDK.
#[derive(Debug, Clone)]
pub struct Client {
inner: reqwest::Client,
}
impl Client {
pub fn new(client: reqwest::Client) -> Self {
Self { inner: client }
}
}
#[derive(Debug)]View on GitHub (pinned to bd85ce9dee)
Solutions
- Remove proxy env vars (HTTP_PROXY/HTTPS_PROXY/ALL_PROXY) in the WASM environment.
- Verify reqwest WASM-compatible features are enabled in the build.
- Check the wrapped inner error for the precise reqwest cause.
- Run the AWS client on a native target if WASM networking limits persist.
Example fix
// before (node/wasm env) process.env.HTTPS_PROXY = "http://proxy:8080"; // unsupported in wasm client // after delete process.env.HTTPS_PROXY;
Defensive patterns
Strategy: try-catch
Validate before calling
if (typeof WebSocket === 'undefined' || process.env.HTTPS_PROXY) { /* wasm reqwest cannot honor proxies */ console.warn('Clear proxy env vars for WASM builds'); } Try / catch
try { initBamlRuntime(); } catch (e) { if (String(e).startsWith('failed to create base http client for WASM')) { console.error('WASM networking init failed; clear proxy settings / check reqwest features'); } throw e; } Prevention
- Do not set proxy env vars in browser/WASM runtimes.
- Compile with WASM-compatible reqwest features.
- Test WASM builds in the target browser environment early.
When it happens
Trigger: Building/running BAML's AWS client under target_arch = wasm32 while crate::request::create_client() fails — e.g. unsupported proxy settings or reqwest WASM feature misconfiguration.
Common situations: Using BAML in a WebAssembly/browser environment with proxy env vars set that the WASM reqwest client cannot honor, or compiling without required reqwest WASM features.
Related errors
- failed to create base http client: {}
- JS callback error: {name}: {message}
- BAML internal error - credential provider bridges not initia
- network error fetching {url}: {source}
- WASM history boundary {} was not begun
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/847f2cb855d7601d.
Report an issue: GitHub.