From a916b041b16e3369c4784b648343c241f4fa6494 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Wed, 16 Nov 2022 10:28:22 +0000 Subject: [PATCH] Detect consumer being deleted in `JetStreamConsumer` --- setup/jetstream/helpers.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/setup/jetstream/helpers.go b/setup/jetstream/helpers.go index 1ec860b0..c1ce9583 100644 --- a/setup/jetstream/helpers.go +++ b/setup/jetstream/helpers.go @@ -2,6 +2,7 @@ package jetstream import ( "context" + "errors" "fmt" "github.com/getsentry/sentry-go" @@ -72,6 +73,9 @@ func JetStreamConsumer( // just timed out and we should try again. continue } + } else if errors.Is(err, nats.ErrConsumerDeleted) { + // The consumer was deleted so stop. + return } else { // Something else went wrong, so we'll panic. sentry.CaptureException(err)