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
This commit is contained in:
@@ -793,10 +793,18 @@
|
|||||||
roots().forEach((root) => {
|
roots().forEach((root) => {
|
||||||
try {
|
try {
|
||||||
bootstrapState(root);
|
bootstrapState(root);
|
||||||
|
} catch (error) {
|
||||||
|
emit(root, "hemx:state-error", String(error));
|
||||||
|
}
|
||||||
|
try {
|
||||||
bindRoot(root);
|
bindRoot(root);
|
||||||
|
} catch (error) {
|
||||||
|
emit(root, "hemx:bind-error", String(error));
|
||||||
|
}
|
||||||
|
try {
|
||||||
bindSse(root);
|
bindSse(root);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
emit(root, "hemx:error", String(error));
|
emit(root, "hemx:sse-error", String(error));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -11,7 +11,9 @@ fn runtime_exposes_debug_api_before_startup_side_effects() {
|
|||||||
.expect("runtime starts after declaration");
|
.expect("runtime starts after declaration");
|
||||||
assert!(api < start);
|
assert!(api < start);
|
||||||
assert!(source.contains("try {\n bootstrapState(root);"));
|
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]
|
#[test]
|
||||||
|
|||||||
Reference in New Issue
Block a user