BoundaryML/baml · error
the browser TypeScript bridge must own the process-wide inbo
Error message
the browser TypeScript bridge must own the process-wide inbound policy
What it means
The WASM entrypoint start() registers the process-wide inbound union ambiguity policy (SelectDefault) and expects registration to succeed. bex_project::register_inbound_union_ambiguity_policy returns Err if the policy was already set, and start() .expect()s on it: 'the browser TypeScript bridge must own the process-wide inbound policy'. It means something else in the process initialized the policy first, so the browser bridge no longer owns it.
Source
Thrown at baml_language/crates/bridge_wasm/src/lib.rs:71
mod wasm_http;
mod wasm_io;
mod wasm_io_fs;
mod wasm_io_glob;
mod wasm_random;
mod wasm_sys;
mod wasm_time;
mod wasm_vfs;
pub use lsp_wire::{LspNotification, LspRequest, LspResponse, LspResponseError};
static LOGGER_INIT: Once = Once::new();
#[wasm_bindgen(start)]
pub fn start() {
bex_project::register_inbound_union_ambiguity_policy(
bex_project::InboundUnionAmbiguityPolicy::SelectDefault,
)
.expect("the browser TypeScript bridge must own the process-wide inbound policy");
#[cfg(feature = "console_error_panic")]
console_error_panic_hook::set_once();
LOGGER_INIT.call_once(|| {
let level = if cfg!(debug_assertions) {
log::Level::Debug
} else {
log::Level::Info
};
wasm_logger::init(wasm_logger::Config::new(level));
});
}
/// Get the version of the `bridge_wasm` crate.
#[wasm_bindgen]
pub fn version() -> String {
baml_version::CANONICAL_VERSION.to_string()
}
View on GitHub (pinned to bd85ce9dee)
Solutions
- Ensure the wasm module is imported/initialized only once per process
- Check that no other bridge or test setup registers the inbound policy before WASM start
- Deduplicate bundle chunks so a single wasm_bindgen start runs
- Use a fresh WASM instance per isolated runtime instead of sharing one globally
Example fix
// before
import wasm1 from 'baml_wasm_bg';
import wasm2 from 'baml_wasm_bg'; // second start() -> panic
// after
export const wasm = await import('baml_wasm_bg'); // single shared import Defensive patterns
Strategy: validation
Validate before calling
if (globalThis.__BAML_WASM_STARTED__) throw new Error('baml wasm already initialized in this process');
await import('baml_wasm_bg'); // single init point
globalThis.__BAML_WASM_STARTED__ = true; Prevention
- Import the wasm package exactly once (single shared module instance)
- Do not pre-register the inbound policy in tests or other bridges
- Deduplicate bundler chunks referencing the wasm bg module
- Use separate runtimes/instances rather than one shared process
When it happens
Trigger: Loading the WASM module twice into the same process/runtime, or another binding (Node bridge, tests) calling register_inbound_union_ambiguity_policy before wasm_bindgen start runs.
Common situations: Double-importing the wasm package (e.g. via two bundle chunks), SSR/test environments pre-initializing bex_project, or mixing the WASM bridge with a native bridge in the same process.
Related errors
- BAML internal error - credential provider bridges not initia
- -32002
- Package initialization failed: {0}
- {0}
- Engine not initialized. Call create_baml_runtime first.
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/74ee3fbe4cf1d03c.
Report an issue: GitHub.