From 504561eab2c5fb5b2e9b9b88160da2dcf2cfa199 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Thu, 4 Apr 2019 23:24:33 +0200 Subject: [PATCH] bump cdproto dep to ignore deprecated events We no longer have to keep a list of deprecated events to avoid panics in cdproto. --- go.mod | 6 +++--- go.sum | 12 ++++++------ target.go | 18 ++++++++---------- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/go.mod b/go.mod index 8eb454c..24aea15 100644 --- a/go.mod +++ b/go.mod @@ -1,9 +1,9 @@ module github.com/chromedp/chromedp require ( - github.com/chromedp/cdproto v0.0.0-20190327003620-8d5e1d04ce19 + github.com/chromedp/cdproto v0.0.0-20190403231133-2aeaf1f9e897 github.com/disintegration/imaging v1.6.0 github.com/gorilla/websocket v1.4.0 - github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe - golang.org/x/image v0.0.0-20190220214146-31aff87c08e9 // indirect + github.com/mailru/easyjson v0.0.0-20190403194419-1ea4449da983 + golang.org/x/image v0.0.0-20190321063152-3fc05d484e9f // indirect ) diff --git a/go.sum b/go.sum index 1e45e99..6f32274 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/chromedp/cdproto v0.0.0-20190327003620-8d5e1d04ce19 h1:KOdZXVcB8L3zR4ZsMAnviYJFIgfRP/iYSEzXl7rYXhc= -github.com/chromedp/cdproto v0.0.0-20190327003620-8d5e1d04ce19/go.mod h1:xquOK9dIGFlLaIGI4c6IyfLI/Gz0LiYYuJtzhsUODgI= +github.com/chromedp/cdproto v0.0.0-20190403231133-2aeaf1f9e897 h1:FKNZWQdZMOZoXB0b7RFgtYKDD7AH7fvwQ8K6b2fZ2sQ= +github.com/chromedp/cdproto v0.0.0-20190403231133-2aeaf1f9e897/go.mod h1:xquOK9dIGFlLaIGI4c6IyfLI/Gz0LiYYuJtzhsUODgI= github.com/disintegration/imaging v1.6.0 h1:nVPXRUUQ36Z7MNf0O77UzgnOb1mkMMor7lmJMJXc/mA= github.com/disintegration/imaging v1.6.0/go.mod h1:xuIt+sRxDFrHS0drzXUlCJthkJ8k7lkkUojDSR247MQ= github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q= @@ -7,10 +7,10 @@ github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoA github.com/knq/sysutil v0.0.0-20181215143952-f05b59f0f307 h1:vl4eIlySbjertFaNwiMjXsGrFVK25aOWLq7n+3gh2ls= github.com/knq/sysutil v0.0.0-20181215143952-f05b59f0f307/go.mod h1:BjPj+aVjl9FW/cCGiF3nGh5v+9Gd3VCgBQbod/GlMaQ= github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe h1:W/GaMY0y69G4cFlmsC6B9sbuo2fP8OFP1ABjt4kPz+w= -github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.0.0-20190403194419-1ea4449da983 h1:wL11wNW7dhKIcRCHSm4sHKPWz0tt4mwBsVodG7+Xyqg= +github.com/mailru/easyjson v0.0.0-20190403194419-1ea4449da983/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81 h1:00VmoueYNlNz/aHIilyyQz/MHSqGoWJzpFv/HW8xpzI= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= -golang.org/x/image v0.0.0-20190220214146-31aff87c08e9 h1:+vH8qNweCrORN49012OX3h0oWEXO3p+rRnpAGQinddk= -golang.org/x/image v0.0.0-20190220214146-31aff87c08e9/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= +golang.org/x/image v0.0.0-20190321063152-3fc05d484e9f h1:FO4MZ3N56GnxbqxGKqh+YTzUWQ2sDwtFQEZgLOxh9Jc= +golang.org/x/image v0.0.0-20190321063152-3fc05d484e9f/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/target.go b/target.go index 19a723b..b0ad051 100644 --- a/target.go +++ b/target.go @@ -3,6 +3,7 @@ package chromedp import ( "context" "encoding/json" + "strings" "sync/atomic" "time" @@ -131,19 +132,16 @@ func (t *Target) processEvent(ctx context.Context, msg *cdproto.Message) error { if msg == nil { return ErrChannelClosed } - switch msg.Method { - case "Page.frameClearedScheduledNavigation", - "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 - } - // unmarshal ev, err := cdproto.UnmarshalMessage(msg) if err != nil { + if strings.Contains(err.Error(), "unknown command or event") { + // This is most likely an event received from an older + // Chrome which a newer cdproto doesn't have, as it is + // deprecated. Ignore that error. + // TODO: use error wrapping once Go 1.13 is released. + return nil + } return err }