bevyengine/bevy · error
Should register `setTimeout`.
Error message
Should register `setTimeout`.
What it means
An expect() failure inside the wasm32 schedule runner build path: the code reaches a branch that requires a registered setTimeout callback (via web_sys::window()), but the browser window/global is unavailable. This is an environment/setup guard on wasm targets, indicating the app is not running inside a proper browser context or the web feature setup is inconsistent.
Source
Thrown at crates/bevy_app/src/schedule_runner.rs:130
let exe_time = end_time - start_time;
if exe_time < wait {
return Ok(Some(wait - exe_time));
}
}
Ok(None)
};
cfg_select! {
all(target_arch = "wasm32", feature = "web") => {
fn set_timeout(callback: &Closure<dyn FnMut()>, dur: Duration) {
web_sys::window()
.unwrap()
.set_timeout_with_callback_and_timeout_and_arguments_0(
callback.as_ref().unchecked_ref(),
dur.as_millis() as i32,
)
.expect("Should register `setTimeout`.");
}
let asap = Duration::from_millis(1);
let exit = Rc::new(RefCell::new(AppExit::Success));
let closure_exit = exit.clone();
let mut app = Rc::new(app);
let moved_tick_closure = Rc::new(RefCell::new(None));
let base_tick_closure = moved_tick_closure.clone();
let tick_app = move || {
let app = Rc::get_mut(&mut app).unwrap();
let delay = tick(app, wait);
match delay {
Ok(delay) => set_timeout(
moved_tick_closure.borrow().as_ref().unwrap(),
delay.unwrap_or(asap),
),View on GitHub (pinned to 396ca72708)
Solutions
- Ensure the app is actually running in a browser environment (wasm32 target with the web feature enabled)
- Enter the app through the #[bevy_main] macro / wasm runner so the browser globals are initialized
- Verify web-sys window access is not happening in a worker or non-window context without a fallback runner
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/bevy_app/src/schedule_runner.rs:130 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
AI-assisted analysis of bevyengine/bevy@396ca72708 (2026-08-20).
Data as JSON: /api/errors/cbe9529c754bf5b8.
Report an issue: GitHub.