fix(chrome): keep the message of an object console argument

Claude-Session: https://claude.ai/code/session_01ShuAy8q8ZfPi8KHxwc8JpQ
This commit is contained in:
pj committed 2026-08-16 01:29:58 +05:30
1 parent 546c80885e
commit 59da61fecb
1 file changed
+14 -6
+14 -6
View File
@@ -70,13 +70,21 @@ func New() *Driver {
} }
var parts []string var parts []string
for _, arg := range e.Args { for _, arg := range e.Args {
if arg.Value != nil { // An object argument, which is what console.error(err) passes,
var s string // carries no value at all: CDP sends a description instead. Reading
if err := json.Unmarshal(arg.Value, &s); err == nil { // only the value logged those calls with an empty message, so the
parts = append(parts, s) // entry named a level and nothing a reader could act on.
} else { if arg.Value == nil {
parts = append(parts, string(arg.Value)) if arg.Description != "" {
parts = append(parts, arg.Description)
} }
continue
}
var s string
if err := json.Unmarshal(arg.Value, &s); err == nil {
parts = append(parts, s)
} else {
parts = append(parts, string(arg.Value))
} }
} }
d.logsMu.Lock() d.logsMu.Lock()