leptos-rs/leptos · error
at {location}, the `sandboxed-arenas` feature is active, but
Error message
at {location}, the `sandboxed-arenas` feature is active, but no Arena is active What it means
reactive_graph's Arena::with reads reactive state through an Arena when the `sandboxed-arenas` feature is enabled. If the closure runs without any Arena active in the current thread/scope, try_with returns None and the library panics, reporting the source location of the call.
Source
Thrown at reactive_graph/src/owner/arena.rs:53
#[cfg(feature = "sandboxed-arenas")]
{
let new_arena = Arc::downgrade(arena);
MAP.with_borrow_mut(|arena| {
*arena = Some(new_arena);
})
}
}
#[track_caller]
pub fn with<U>(fun: impl FnOnce(&ArenaMap) -> U) -> U {
#[cfg(not(feature = "sandboxed-arenas"))]
{
fun(&MAP.get_or_init(Default::default).read().or_poisoned())
}
#[cfg(feature = "sandboxed-arenas")]
{
Arena::try_with(fun).unwrap_or_else(|| {
panic!(
"at {}, the `sandboxed-arenas` feature is active, but no \
Arena is active",
std::panic::Location::caller()
)
})
}
}
#[track_caller]
pub fn try_with<U>(fun: impl FnOnce(&ArenaMap) -> U) -> Option<U> {
#[cfg(not(feature = "sandboxed-arenas"))]
{
Some(fun(&MAP.get_or_init(Default::default).read().or_poisoned()))
}
#[cfg(feature = "sandboxed-arenas")]
{
MAP.with_borrow(|arena| {
arenaView on GitHub (pinned to 32d20f6c9d)
Solutions
- Create and enter an Arena before the call so try_with succeeds.
- Disable the `sandboxed-arenas` feature if you rely on the default global MAP storage.
- Ensure tasks touching reactive state are spawned inside the Arena's scope or receive values explicitly.
Example fix
// before let value = Arena::with(|map| compute(map)); // panics: no active arena // after let arena = Arena::new(); let value = arena.enter(|| Arena::with(|map| compute(map)));
Defensive patterns
Strategy: validation
Validate before calling
fn arena_active() -> bool {
Arena::try_with(|_| ()).is_some()
}
// call before reactive reads when sandboxed-arenas is enabled Try / catch
let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
Arena::with(|map| compute(map))
})); Prevention
- Enter an Arena at the top of every thread/task that touches reactive state.
- Only enable sandboxed-arenas when you control all state-access entry points.
- Add tests that run reactive reads with the feature enabled.
When it happens
Trigger: Enabling the `sandboxed-arenas` cargo feature and then calling Arena::with(...) (or any reactive read routed through it) outside of an Arena-entered scope.
Common situations: Testing or benchmarking with sandboxed-arenas enabled but creating the Arena only in part of the code; background threads/spawned tasks accessing reactive values without entering an Arena first.
Related errors
- Unsupported server function HTTP method: {method:?}
- {}
- Reading from a LocalResource outside Suspense in `ssr` mode
- {location:?} expected context of type {type_name:?} to be pr
- Tried to access a reactive value that has already been dispo
AI-assisted analysis of leptos-rs/leptos@32d20f6c9d (2026-09-01).
Data as JSON: /api/errors/b4497a5549c7d740.
Report an issue: GitHub.