From 4069bbe263c948732a07bb071f55b54c4c8489a2 Mon Sep 17 00:00:00 2001 From: Snider Date: Wed, 15 Apr 2026 23:52:21 +0100 Subject: [PATCH] Guard watcher constructors against nil clients --- console.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/console.go b/console.go index 9e27faf..09dc3c9 100644 --- a/console.go +++ b/console.go @@ -49,6 +49,10 @@ func NewConsoleWatcher(wv *Webview) *ConsoleWatcher { handlers: make([]consoleHandlerRegistration, 0), } + if wv == nil || wv.client == nil { + return watcher + } + // Subscribe to console events from the webview's client wv.client.OnEvent("Runtime.consoleAPICalled", func(params map[string]any) { watcher.handleConsoleEvent(params) @@ -529,6 +533,10 @@ func NewExceptionWatcher(wv *Webview) *ExceptionWatcher { handlers: make([]exceptionHandlerRegistration, 0), } + if wv == nil || wv.client == nil { + return ew + } + // Subscribe to exception events wv.client.OnEvent("Runtime.exceptionThrown", func(params map[string]any) { ew.handleException(params)