Skip to content

124: enable handling socket errors - #125

Merged
mkenney merged 13 commits into
masterfrom
124/socket-error-handling
Sep 25, 2018
Merged

mkenney merged 13 commits into
masterfrom
124/socket-error-handling

Conversation

@mkenney

@mkenney mkenney commented Sep 24, 2018 •

Copy link
Copy Markdown
Owner

Change type

What types of changes does your code introduce to go-chrome?

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Other (please explain here)

This changes the Socketer interface, removing the error return value from the Stop method and adding an Errors method that returns an error channel.

Checklist

  • I have read the CONTRIBUTING guidelines.
  • Lint and unit tests pass locally with my changes.
  • I have created tests which fail without the change (if possible) and prove my fix is effective or that my feature works.
  • I have added necessary documentation (if appropriate).

What does this implement/fix? Please explain these changes.

  • recovers from websocket panics produced in the github.com/gorilla/websocket package
  • provides an error channel for accessing errors in the socket listener
  • adds initial error codes

Does this close any currently open issues?

#124

Any relevant logs, error output, etc?

error 2018-09-23T20:28:42.226-06:00 nil response from socket
   ⇢  socketID=1
   ⇢  socket.socketer.go:344 github.com/mkenney/go-chrome/tot/socket.(*Socket).listen
error 2018-09-23T20:28:42.226-06:00 Unknown response from web socket
   ⇢  data="{\\\"error\\\":null,\\\"id\\\":0,\\\"method\\\":\\\"\\\",\\\"params\\\":null,\\\"result\\\":null}" method="" responseID=0 socketID=1
   ⇢  socket.socketer.go:368 github.com/mkenney/go-chrome/tot/socket.(*Socket).listen
error 2018-09-23T20:28:43.228-06:00 2000: An unknown error occurred
   ⇢  error="recovered from panic in Socket.listen()"
   ⇢  socket.socketer.go:315 github.com/mkenney/go-chrome/tot/socket.(*Socket).listen.func1
#0: `github.com/mkenney/go-chrome/tot/socket.(*Socket).listen.func1`
        error:   recovered from panic in Socket.listen()
        line:    socket.socketer.go:309
        code:    2000: A panic occurred while reading from a websocket
        message: 2000: An unknown error occurred

Any other comments?

Comment thread tot/socket/socket.socketer.go Outdated
connected bool
errCh chan error
handlers EventHandlerMapper
lastErr error

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lastErr is unused

Comment thread tot/socket/socket.socketer.go Outdated
listening bool
mux *sync.Mutex
newSocket func(socketURL *url.URL) (WebSocketer, error)
socketErr error

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

socketErr is unused

@mkenney mkenney mentioned this pull request Sep 24, 2018
@mkenney mkenney added the feedback wanted Looking for community feedback on this discussion. label Sep 24, 2018
@mkenney mkenney added this to the v1.0.0 milestone Sep 24, 2018
@mkenney mkenney self-assigned this Sep 24, 2018
@mkenney
mkenney merged commit 506945c into master Sep 25, 2018
@mkenney
mkenney deleted the 124/socket-error-handling branch September 25, 2018 04:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feedback wanted Looking for community feedback on this discussion.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

⌂ 换网址