Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnmarshalMessage panics when encountering deprecated messages #2

Closed
mvdan opened this issue Mar 28, 2019 · 4 comments
Closed

UnmarshalMessage panics when encountering deprecated messages #2

mvdan opened this issue Mar 28, 2019 · 4 comments

Comments

@mvdan
Copy link
Contributor

mvdan commented Mar 28, 2019

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

@kenshaw
Copy link
Member

kenshaw commented Apr 3, 2019

Sorry; missed this a week ago. Writing a fix now.

@kenshaw
Copy link
Member

kenshaw commented Apr 3, 2019

Fixed.

@kenshaw kenshaw closed this as completed Apr 3, 2019
@haohanger
Copy link

@kenshaw

got rid of Page.frameRequestedNavigation and all of its types. In UnmarshalMessage, that event method now doesn't fall under any of the cases, Page. FrameRequestedNavigation also need for processing,Like this:

switch msg.Method {
case "Page.frameClearedScheduledNavigation",
"Page.frameRequestedNavigation",
"Page.frameScheduledNavigation":
// These events are now deprecated, and UnmarshalMessage panics
// when they are received from Chrome. For now, to avoid panics
// and compile errors, and to fix chromedp v0 when installed via
// 'go get -u', skip the events here.
return nil
}

@mvdan
Copy link
Contributor Author

mvdan commented Jun 20, 2019

@haohanger please file a new issue, following the issue template.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants