{"record":{"id":"847f2cb855d7601d","repo":"BoundaryML/baml","slug":"failed-to-create-base-http-client-for-wasm","errorCode":null,"errorMessage":"failed to create base http client for WASM: {}","messagePattern":"failed to create base http client for WASM: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-runtime/src/internal/llm_client/primitive/aws/custom_http_client.rs","lineNumber":34,"sourceCode":"// --- WASM specific imports ---\n#[cfg(target_arch = \"wasm32\")]\nuse {futures::channel::oneshot, wasm_bindgen_futures::spawn_local};\n\nuse crate::request::create_client;\n\n/// Returns a wrapper around the global reqwest client.\n/// [HttpClient].\n#[cfg(not(target_arch = \"wasm32\"))] // Keep function non-WASM for now\npub fn client() -> anyhow::Result<Client> {\n    let client = crate::request::create_client()\n        .map_err(|e| anyhow::anyhow!(\"failed to create base http client: {}\", e))?;\n    Ok(Client::new(client.clone()))\n}\n\n#[cfg(target_arch = \"wasm32\")] // Define WASM client function\npub fn client() -> anyhow::Result<Client> {\n    let client = crate::request::create_client()\n        .map_err(|e| anyhow::anyhow!(\"failed to create base http client for WASM: {}\", e))?;\n    Ok(Client::new(client.clone()))\n}\n\n/// A wrapper around [reqwest::Client] that implements [HttpClient].\n///\n/// This is required to support using proxy servers with the AWS SDK.\n#[derive(Debug, Clone)]\npub struct Client {\n    inner: reqwest::Client,\n}\n\nimpl Client {\n    pub fn new(client: reqwest::Client) -> Self {\n        Self { inner: client }\n    }\n}\n\n#[derive(Debug)]","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-runtime/src/internal/llm_client/primitive/aws/custom_http_client.rs#L16-L52","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before (node/wasm env)\nprocess.env.HTTPS_PROXY = \"http://proxy:8080\"; // unsupported in wasm client\n// after\ndelete process.env.HTTPS_PROXY;","handlingStrategy":"try-catch","validationCode":"if (typeof WebSocket === 'undefined' || process.env.HTTPS_PROXY) { /* wasm reqwest cannot honor proxies */ console.warn('Clear proxy env vars for WASM builds'); }","typeGuard":null,"tryCatchPattern":"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; }","preventionTips":["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."],"tags":["wasm","http-client","reqwest","aws","init"],"backgroundTag":"module-init-failed","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"}