Skip to content

Commit

Permalink
only execute stream callback when non-nil (#121)
Browse files Browse the repository at this point in the history
Currently, if `nil` is returned as a stream callback, it will cause a
panic because we try to call a `nil` func. This makes it valid to return
a `nil` callback from the stream job, which just does nothing on
callback.
  • Loading branch information
Kimi.Wang authored and camdencheek committed Nov 12, 2023
1 parent abd9a8b commit b528efd
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion stream/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ func (s *Stream) callbacker() {
callback := <-callbackCh

// Execute the callback (with panic protection).
panicCatcher.Try(callback)
if callback != nil {
panicCatcher.Try(callback)
}

// Return the channel to the pool of unused channels.
putCh(callbackCh)
Expand Down

0 comments on commit b528efd

Please sign in to comment.