From 619b3c500dc9901e604e32a3cfb79f9d0f99e2e3 Mon Sep 17 00:00:00 2001 From: Virgil Date: Sat, 4 Apr 2026 23:16:18 +0000 Subject: [PATCH] refactor(proxy): isolate event bus panics Co-Authored-By: Virgil --- core_impl.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/core_impl.go b/core_impl.go index 60ea1ae..a30ab4d 100644 --- a/core_impl.go +++ b/core_impl.go @@ -52,6 +52,9 @@ func getSplitterFactory(mode string) (func(*Config, *EventBus) Splitter, bool) { // LoadConfig reads and unmarshals a JSON config file. // // cfg, result := LoadConfig("config.json") +// if !result.OK { +// return +// } func LoadConfig(path string) (*Config, Result) { data, err := os.ReadFile(path) if err != nil { @@ -143,7 +146,12 @@ func (b *EventBus) Dispatch(e Event) { handlers := append([]EventHandler(nil), b.listeners[e.Type]...) b.mu.RUnlock() for _, handler := range handlers { - handler(e) + func() { + defer func() { + _ = recover() + }() + handler(e) + }() } }