From 6759f42a4c1d9599fea002f05c5fa06e4f2f61b3 Mon Sep 17 00:00:00 2001 From: Snider Date: Wed, 15 Apr 2026 23:54:06 +0100 Subject: [PATCH] Align webview console and tab lifecycle --- cdp.go | 6 ++++-- console.go | 7 +++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/cdp.go b/cdp.go index cf6517a..8d9b825 100644 --- a/cdp.go +++ b/cdp.go @@ -322,6 +322,9 @@ func (c *CDPClient) CloseTab() error { if err != nil { return coreerr.E("CDPClient.CloseTab", "failed to determine target ID", err) } + defer func() { + _ = c.Close() + }() ctx, cancel := context.WithTimeout(c.ctx, debugEndpointTimeout) defer cancel() @@ -336,8 +339,7 @@ func (c *CDPClient) CloseTab() error { if success, ok := result["success"].(bool); ok && !success { return coreerr.E("CDPClient.CloseTab", "target close was not acknowledged", nil) } - - return c.Close() + return nil } // ListTargets returns all available targets. diff --git a/console.go b/console.go index 09dc3c9..4e7a66b 100644 --- a/console.go +++ b/console.go @@ -61,14 +61,13 @@ func NewConsoleWatcher(wv *Webview) *ConsoleWatcher { return watcher } -// normalizeConsoleType converts CDP event types to package-level values. +// normalizeConsoleType converts CDP event types to the canonical package value. // -// This keeps the legacy warn alias for compatibility. Use canonicalConsoleType -// when the exact RFC type names are required. +// It accepts legacy warn aliases but stores the RFC form, warning. func normalizeConsoleType(raw string) string { normalized := strings.ToLower(core.Trim(core.Sprint(raw))) if normalized == "warning" { - return "warn" + return "warning" } return normalized }