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

Commit

Permalink
chore: log only if there are no error handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
olegbespalov committed Jun 14, 2023
1 parent ff38c31 commit 8b18ee9
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions grpc/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,16 +281,9 @@ 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
err = nil
}

s.logger.WithError(err).Error("failed to send data to the stream")
s.tq.Queue(func() error {
return s.closeWithError(err)
})
Expand Down Expand Up @@ -365,7 +358,13 @@ func (s *stream) callErrorListeners(e error) error {

obj := extractError(e)

for _, errorListener := range s.eventListeners.all(eventError) {
list := s.eventListeners.all(eventError)

if len(list) == 0 {
s.logger.Errorf("no handlers for error registered, but an error happened: %s", e)
}

for _, errorListener := range list {
if _, err := errorListener(rt.ToValue(obj)); err != nil {
return err
}
Expand Down

0 comments on commit 8b18ee9

Please sign in to comment.