Recover from panicking notifier subscribers#1270
Closed
peter941221 wants to merge 2 commits into
Closed
Conversation
brandur
reviewed
Jun 3, 2026
Contributor
brandur
left a comment
There was a problem hiding this comment.
Just since all notification callbacks are internal code right now, I think we might want to leave this as is — a panic would be a clear bug, and it'd be nice to know about it ASAP instead of it getting swallowed up in a test log somewhere.
Contributor
Author
|
@brandur sure, I'll close this one. |
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.
Notifier delivers subscriber callbacks from a shared delivery goroutine in
deliverNotifications. Right now, one panicking callback can take down that goroutine and stop delivery for unrelated subscribers.Wrap each subscriber callback invocation in local panic recovery.
If one subscriber panics, River now logs the panic value and notification topic, then continues delivering to later subscribers and stays alive for future notifications.
This keeps the fix at the narrowest boundary that owns the risk: the callback fan-out loop.
It does not change the subscription API or the notifier control flow. It only prevents one bad subscriber from killing delivery for everyone else.
Added
PanicInSubscriberDoesNotBreakDeliveryininternal/notifier/notifier_test.go.The test drives
notificationBufdirectly so it stays unit-scoped. It proves that: