decentraland / decentraland/bevy-explorer
Scene thread: shut down on consecutive errors without renderer comms, not on a cumulative count
- Dominant language
- Rust
- Stars
- 27
- Forks
- 20
- Avg merge
- 1d 30m
- Merged PRs (30d)
- 78
Description
`crates/dcl_deno/src/js/mod.rs:399` decides whether to kill a scene thread with:
```rust
if reported_errors == 10
&& state.borrow().try_borrow::().is_none()
```
Two problems with that shape.
**The count is cumulative, so the check is a single instant.** `reported_errors` only ever increases, and the guard uses exact equality. A scene that throws 10 uncaught errors over its lifetime while communicating normally passes the `== 10` moment with `CommunicatedWithRenderer` present, and is then never evaluated again — at 11 errors the condition can no longer be true. If that scene later stops talking to the renderer entirely, nothing shuts it down; it keeps burning a thread and a V8 isolate.
**It measures the wrong thing.** The intent is "this scene is failing and not making progress". Consecutive errors since the last successful renderer interaction expresses that; a lifetime total does not. A long-lived scene accrues errors harmlessly, and the current form spends its one chance early.
Suggested shape: track consecutive errors, reset the counter whenever the scene reaches the renderer interface, and shut down when that run of consecutive errors crosses the threshold. That keeps the existing "don't exit on uncaught onUpdate errors alone" behaviour while actually catching the case the guard was written for.
Matters more for the authoritative server (#974), where scenes are co-tenanted and a wedged scene's thread and isolate are charged to a shared host.
Found during review of #974; out of scope there.
Contributor guide
Assessment
This issue has not been assessed yet.