Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Commit

Permalink
fix: omit reporting EOF errors
Browse files Browse the repository at this point in the history
  • Loading branch information
olegbespalov committed Jun 14, 2023
1 parent 6095be0 commit 930fb5c
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions grpc/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,7 @@ func (s *stream) writeData(wg *sync.WaitGroup) {

err := s.stream.Send(msg.msg)
if err != nil {
s.logger.WithError(err).Error("failed to send data to the stream")

s.tq.Queue(func() error {
return s.closeWithError(err)
})

s.processSendError(err)
return
}

Expand Down Expand Up @@ -284,6 +279,23 @@ func (s *stream) writeData(wg *sync.WaitGroup) {
}
}

func (s *stream) processSendError(err error) {
if errors.Is(err, io.EOF) {
s.logger.WithError(err).Debug("can't send data to the closed stream")

s.tq.Queue(func() error {
return s.closeWithError(nil)
})

return
}

s.tq.Queue(func() error {
return s.closeWithError(nil)
})
s.logger.WithError(err).Error("failed to send data to the stream")
}

// on registers a listener for a certain event type
func (s *stream) on(event string, listener func(goja.Value) (goja.Value, error)) {
if err := s.eventListeners.add(event, listener); err != nil {
Expand Down

0 comments on commit 930fb5c

Please sign in to comment.