BoundaryML/baml · error
No tracer found
Error message
No tracer found
What it means
get_tracer assumes the internal tracers map always holds at least one tracer and unwraps its first entry on the wasm32 target. If the map is empty (no tracer was ever created, or all were cleared), expect panics with 'No tracer found'. It is a guard against an invariant violation in tracer lifecycle management.
Source
Thrown at engine/baml-runtime/src/lib.rs:224
}
}
// Config changed, clear all and insert new
self.tracers.clear();
let new_tracer = Arc::new(
BamlTracer::new(None, filtered.clone().into_iter())
.expect("Failed to create BamlTracer"),
);
self.tracers.insert(key, new_tracer.clone());
new_tracer
}
}
/// Get the current tracer (the only one in the map, if any).
pub fn get_tracer(&self) -> Arc<BamlTracer> {
#[cfg(target_arch = "wasm32")]
{
let tracers = self.tracers.lock().unwrap();
tracers.values().next().expect("No tracer found").clone()
}
#[cfg(not(target_arch = "wasm32"))]
{
self.tracers.iter().next().expect("No tracer found").clone()
}
}
}
cfg_if::cfg_if!(
if #[cfg(target_arch = "wasm32")] {
type DashMap<K, V> = std::sync::Arc<std::sync::Mutex<std::collections::HashMap<K, V>>>;
} else {
use dashmap::DashMap;
}
);
/// RAII guard that ensures both TraceEvent::new_function_end and finish_baml_call
/// are properly called, even if the function returns early due to an error.View on GitHub (pinned to bd85ce9dee)
Solutions
- Ensure get_or_create_tracer is called (and succeeds) before any get_tracer call
- Return an Option/Result from get_tracer instead of expect so callers can handle the empty case
- Check application initialization order so the runtime is fully constructed before tracing APIs are used
- Fix any failing tracer creation path that clears the map but fails to insert a replacement
Defensive patterns
Strategy: validation
Validate before calling
// wasm caller check before use
if tracers_len(tracer_map) == 0 {
tracer = get_or_create_tracer(config);
} Prevention
- Always initialize the runtime (get_or_create_tracer) before tracing calls
- Never leave the tracers map empty after a config-change clear
- Use a Result-returning accessor in wrapper code
When it happens
Trigger: Calling BamlRuntime::get_tracer on wasm32 when the tracers mutex map contains no entries — i.e. get_or_create_tracer was never called or the map was cleared by a config-change path that failed before inserting a new tracer.
Common situations: Accessing the tracer before runtime initialization completes; a prior get_or_create_tracer panicked and left the map empty; single-page-app reloads that recreate runtime state out of order.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- VM internal error: {0}
- BAML internal error (AWSBedrock): file should have been reso
- Failed to send cred request across WASM bridge: {0}
- Failed to recv cred response across WASM bridge: {0}
- Function log expected to be present (no FunctionStart event?
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/b7d334b8a4ce79f4.
Report an issue: GitHub.