Skip to content

Fix NRE in DurableReceiver when Listener is null during redelivery#2263

Merged
jeremydmiller merged 1 commit intomainfrom
fix/durable-receiver-null-listener-nre
Mar 5, 2026
Merged

Fix NRE in DurableReceiver when Listener is null during redelivery#2263
jeremydmiller merged 1 commit intomainfrom
fix/durable-receiver-null-listener-nre

Conversation

@jeremydmiller
Copy link
Member

Summary

  • When DurableReceiver is latched and receives an envelope, ReceivedAsync posts to _deferBlock (line 252) before MarkReceived sets envelope.Listener, causing env.Listener!.DeferAsync(env) to throw a NullReferenceException.
  • Added a null guard on envelope.Listener before posting to _deferBlock, consistent with every other call site for _deferBlock and _completeBlock in the class (lines 201, 258, 375, 436, 446).
  • If the listener is null when latched, the envelope is already persisted in the inbox and will be recovered by the durability agent — no action on the transport listener is needed.

Closes #2258

Test plan

  • durable_receiver_latched_without_listener.should_not_throw_nre_and_should_not_invoke_pipeline — verifies no NRE when listener is null
  • durable_receiver_latched_without_listener.should_defer_on_listener_when_envelope_has_listener — verifies defer still works when listener is present

🤖 Generated with Claude Code

…ivery

When DurableReceiver is latched and receives an envelope, it posts to
_deferBlock before MarkReceived sets envelope.Listener, causing a
NullReferenceException. Added a null guard consistent with all other
_deferBlock and _completeBlock call sites in the class.

Closes #2258

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NRE in DurableReceiver when Listener is null during redelivery

1 participant