From 736f9f3c7ef26a9505d6175033faaad854a5dcb1 Mon Sep 17 00:00:00 2001 From: slhx agent Date: Fri, 5 Jun 2026 20:34:08 +0200 Subject: [PATCH] fix(js): isolate startup binding failures Keep the public runtime API available and report state, binding, and SSE startup errors independently so one startup failure cannot hide the runtime object or other roots. req: runtime/002 --- hemx-js/runtime/hemx.js | 10 +++++++++- hemx-js/tests/runtime.rs | 4 +++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/hemx-js/runtime/hemx.js b/hemx-js/runtime/hemx.js index fcee9f0..4391c01 100644 --- a/hemx-js/runtime/hemx.js +++ b/hemx-js/runtime/hemx.js @@ -793,10 +793,18 @@ roots().forEach((root) => { try { bootstrapState(root); + } catch (error) { + emit(root, "hemx:state-error", String(error)); + } + try { bindRoot(root); + } catch (error) { + emit(root, "hemx:bind-error", String(error)); + } + try { bindSse(root); } catch (error) { - emit(root, "hemx:error", String(error)); + emit(root, "hemx:sse-error", String(error)); } }); try { diff --git a/hemx-js/tests/runtime.rs b/hemx-js/tests/runtime.rs index 5ef2a9d..b97aff6 100644 --- a/hemx-js/tests/runtime.rs +++ b/hemx-js/tests/runtime.rs @@ -11,7 +11,9 @@ fn runtime_exposes_debug_api_before_startup_side_effects() { .expect("runtime starts after declaration"); assert!(api < start); assert!(source.contains("try {\n bootstrapState(root);")); - assert!(source.contains("emit(root, \"hemx:error\", String(error));")); + assert!(source.contains("emit(root, \"hemx:state-error\", String(error));")); + assert!(source.contains("try {\n bindRoot(root);")); + assert!(source.contains("emit(root, \"hemx:bind-error\", String(error));")); } #[test]