refactor(proxy): isolate event bus panics

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Virgil 2026-04-04 23:16:18 +00:00
parent 8a321e2467
commit 619b3c500d

View file

@ -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)
}()
}
}