Skip to content

Commit 0135d93

Browse files
authored
fix(pubsub/v2): respect ShutdownBehavior when handling timeout (#13021)
Previously, `ShutdownOptions.Behavior` was never respected — when a positive `Timeout` was set, messages were always nacked. This PR fixes the shutdown logic so that messages are only nacked if `Behavior` is explicitly set to `ShutdownBehaviorNackImmediately`. This makes the `Behavior` field effective as intended. related to #12829
1 parent 800b556 commit 0135d93

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pubsub/v2/subscriber.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,8 +481,10 @@ func (s *Subscriber) Receive(ctx context.Context, f func(context.Context, *Messa
481481
p.iter.ps.cancel()
482482
}
483483
time.AfterFunc(shutdownOpts.Timeout, shutdownKillCancel)
484-
for _, p := range pairs {
485-
p.iter.nackInventory(shutdownKillCtx)
484+
if shutdownOpts.Behavior == ShutdownBehaviorNackImmediately {
485+
for _, p := range pairs {
486+
p.iter.nackInventory(shutdownKillCtx)
487+
}
486488
}
487489
}
488490

0 commit comments

Comments
 (0)