Skip to content

Commit e0db124

Browse files
committed
fix: unsubscribe channel if start the consumer
Signed-off-by: Bo-Yi Wu <[email protected]>
1 parent 0cbfbd1 commit e0db124

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

nats.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,11 @@ func (w *Worker) Shutdown() error {
136136
}
137137

138138
w.stopOnce.Do(func() {
139-
_ = w.subscription.Unsubscribe()
139+
// unsubscribe channel if start the consumer
140+
if w.subscription != nil {
141+
_ = w.subscription.Unsubscribe()
142+
}
143+
140144
close(w.stop)
141145
select {
142146
case <-w.exit:

0 commit comments

Comments
 (0)