Fix NullReferenceException in rate-limited listener pause/resume#2254
Merged
jeremydmiller merged 1 commit intomainfrom Mar 2, 2026
Merged
Fix NullReferenceException in rate-limited listener pause/resume#2254jeremydmiller merged 1 commit intomainfrom
jeremydmiller merged 1 commit intomainfrom
Conversation
…imiting Guard against null Envelope and null Listener in PauseListenerContinuation to prevent NRE when multiple rate-limited messages trigger concurrent pause/resume cycles. Apply defensive copy pattern in ListeningAgent StopAndDrainAsync and RabbitMqListener StopAsync to eliminate TOCTOU race conditions where Listener/Channel could become null between check and use. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This was referenced Mar 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PauseListenerContinuation.ExecuteAsyncagainst nullEnvelopeand nullListener, falling back toEnvelope.Destinationwhen the listener reference is unavailableListeningAgent.StopAndDrainAsyncto captureListener/_receiverinto locals before nulling the fields, eliminating a TOCTOU race where concurrent callers could see null between check and useRabbitMqListener.StopAsyncfor_consumerandChannelObjectDisposedExceptionin listener disposal for rapid pause/stop cyclesAddresses the bug described in #2242: when multiple messages exceed a rate limit simultaneously, the first triggers
PauseListenerContinuationwhich stops the listener (settingListener = null), and subsequent messages hit aNullReferenceExceptiononlifecycle.Envelope!.Listener!.Address.Test plan
PauseListenerContinuationwith null envelope and null listenerNullReferenceExceptionduring concurrent pause/resume cycles🤖 Generated with Claude Code