| From 83ad651cd49fd42ad67bf20e9e6fbebb538156f9 Mon Sep 17 00:00:00 2001 |
| From: Willie Koomson <wvk@google.com> |
| Date: Tue, 23 Jun 2020 11:56:50 -0700 |
| Subject: [PATCH] Check for websocket.CloseError in session.Manager.watch() |
| GitHub issue: https://github.com/mafredri/cdp/issues/120 |
| GitHub PR: https://github.com/mafredri/cdp/pull/121 |
| --- |
| session/manager.go | 6 ++++++ |
| 1 file changed, 6 insertions(+) |
| |
| diff --git a/session/manager.go b/session/manager.go |
| index 374f458..48fbed4 100644 |
| --- a/session/manager.go |
| +++ b/session/manager.go |
| @@ -4,6 +4,7 @@ import ( |
| "context" |
| "time" |
| |
| + "github.com/gorilla/websocket" |
| "github.com/mafredri/cdp" |
| "github.com/mafredri/cdp/internal/errors" |
| "github.com/mafredri/cdp/protocol/target" |
| @@ -79,6 +80,11 @@ func (m *Manager) watch(ev *sessionEvents, created <-chan *session, done, errC c |
| m.cancel() |
| return true |
| } |
| + // Test if this is a websocket.CloseError |
| + if _, ok := e.(*websocket.CloseError); ok { |
| + m.cancel() |
| + return true |
| + } |
| } |
| if cdp.ErrorCause(err) == context.Canceled { |
| // Manager was closed. |
| -- |
| 2.27.0.111.gc72c7da667-goog |
| |