diff --git a/spork/stream.janet b/spork/stream.janet index a60a100..c70113e 100644 --- a/spork/stream.janet +++ b/spork/stream.janet @@ -34,7 +34,7 @@ from the channel, or close the stream and the channel. Otherwise, the task remains frozen in the background. After the channel gives the last line, the channel is closed. After stream or channel is closed, the channel gives `nil`. If `supervisor` is a channel, the channel is used as the supervisor channel. If `supervisor` is nil or not specified, the - task inherits the current supervisor channel. + task inherits the current supervisor channel. The supervisor channel will be given stream errors. ``` [stream &named separator supervisor] (def fiber (lines stream :separator separator)) @@ -42,7 +42,10 @@ (defn give-lines [] (when-let [line (resume fiber)] - (ev/give ch line) + (try + (ev/give ch line) + # If channel is already closed, don't throw an error because channel errors are not interesting. + ([_])) (give-lines))) (ev/go |(defer (:close ch) (give-lines))