Skip to content
This repository has been archived by the owner on Jan 30, 2025. It is now read-only.

Commit

Permalink
Fix unnecessary session unmarshal warning
Browse files Browse the repository at this point in the history
  • Loading branch information
inancgumus committed Dec 2, 2021
1 parent 1f30c11 commit 9bc1396
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions common/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,19 @@ func (s *Session) readLoop() {
select {
case msg := <-s.readCh:
ev, err := cdproto.UnmarshalMessage(msg)
if errors.Is(err, cdp.ErrUnknownCommandOrEvent("")) && msg.Method == "" {
// Results from commands may not always have methods in them.
// This is the reason of this error. So it's harmless.
//
// Also:
// 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, and emit raw cdproto.Message.
s.emit("", msg)
continue
}
if err != nil {
s.logger.Debugf("Session:readLoop:<-s.readCh", "sid:%v tid:%v cannot unmarshal: %v", s.id, s.targetID, err)
if _, ok := err.(cdp.ErrUnknownCommandOrEvent); ok {
// 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, and emit raw cdproto.Message.
s.emit("", msg)
continue
}
state.Logger.Errorf("%s", err)
continue
}
Expand Down

0 comments on commit 9bc1396

Please sign in to comment.