fix(consumer): derive controllerCtx from Background, not caller context#368
Merged
Conversation
This was referenced Jul 14, 2026
c8ad4fe to
dfc9e0a
Compare
dfc9e0a to
815e2b5
Compare
behinddwalls
approved these changes
Jul 14, 2026
Collaborator
ReviewVerdict: ✅ LGTM — the fix is correct, the bug is real, and the test is well-constructed. Two minor doc-level suggestions below. Correctness — verified
Test quality — good
Suggestions (minor, non-blocking)
RiskLow. The only behavioral change is that consume loops no longer die on parent-context cancellation — which is exactly the bug being fixed, and |
815e2b5 to
acf4e77
Compare
consumer.subscribe created controllerCtx from the caller's ctx, which inherits any deadline (e.g. Fx OnStart's 15-second timeout). The consume loop selects on controllerCtx.Done() and exits when the deadline fires, silently dropping all subsequent messages. The subscriber already uses context.Background(); this aligns the consumer to match.
acf4e77 to
345a856
Compare
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
consumer.subscribecreatedcontrollerCtxfrom the caller'sctx, which inherits any deadline (e.g. FxOnStart's 15-second timeout). The consume loop selects oncontrollerCtx.Done()and exits when the deadline fires, silently dropping all subsequent messages.context.Background(); this aligns the consumer to match.Stop()is the shutdown mechanism, not caller context cancellation.Test plan
TestConsumer_ConsumeLoopSurvivesCallerDeadline: starts the consumer with a 50ms deadline context, waits for expiry, delivers a message, asserts it is processed