Skip to content

UnmarshalMessage panics when encountering deprecated messages #2

Closed
@mvdan

Description

@mvdan

For example, 8d5e1d0 got rid of Page.frameScheduledNavigation and all of its types. In UnmarshalMessage, that event method now doesn't fall under any of the cases, and ends up calling json.Unmarshal(buf, v) where v == nil.

The fix here is probably to modify cdproto-gen so that UnmarshalMessage handles this case gracefully:

diff --git a/cdproto.go b/cdproto.go
index 21f111e..fb513e9 100644
--- a/cdproto.go
+++ b/cdproto.go
@@ -2243,6 +2243,9 @@ func UnmarshalMessage(msg *Message) (interface{}, error) {

        case EventTracingTracingComplete:
                v = new(tracing.EventTracingComplete)
+
+       default:
+               return nil, errors.New("unknown or deprecated event method")
        }

        var buf easyjson.RawMessage

I've worked around this in chromedp v0 by capturing these events before the function is called, which is not ideal: chromedp/chromedp@e9aa66f

/cc @kenshaw

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions