Rusi transport emit subscription errors#51
Merged
oncicaradupopovici merged 3 commits intoMay 18, 2026
Conversation
🦋 Changeset detectedLatest commit: e3b6b70 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the Rusi transport subscription wrapper so subscription-level gRPC stream failures (error/end) are surfaced to consumers via the returned Subscription EventEmitter, instead of only being logged.
Changes:
- Forward gRPC
callstreamerrorevents to the subscription (sub.emit('error', e)). - Treat unexpected
endof the stream as a subscription error and emit it to the subscription. - Update unsubscribe logic to remove listeners before cancelling, and add tests for listener wiring and emitted errors.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| packages/message-bus/src/transport/rusi/index.ts | Reworks rusiSubscription to listen for call error/end and forward them to the returned subscription; updates unsubscribe teardown. |
| packages/message-bus/tests/transport/rusi.test.ts | Adds unit tests validating listener registration/removal and that error/end propagate to subscribers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…eners Agent-Logs-Url: https://github.com/osstotalsoft/rocket-toolkit/sessions/f2c81a82-28be-4965-af10-667a79dbfd83 Co-authored-by: oncicaradupopovici <4567203+oncicaradupopovici@users.noreply.github.com>
fraliv13
approved these changes
May 18, 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.
Problem
When the rusi sidecar returns subscription-level stream errors (e.g.
stan: subscribe request timeout), the gRPC channel remainsREADYso no connection-level error fires. The rusi transport only logged these errors and never forwarded them to theSubscriptionEventEmitter, causing subscribers to silently hang with no possibility of recovery.Solution
Rewrite
rusiSubscriptionto forwardcallstream errors and end events onto the subscription's EventEmitter, so callers (e.g.messaging-host) can react to subscription-level failures.Changes
rusiSubscription(call, subject)onErrorhandler: logs the error and callssub.emit('error', e)onEndhandler: synthesises anErrorand callssub.emit('error', err)— a stream ending unexpectedly is treated as an errorunsubscribe()removes both listeners viaremoveListenerbefore callingcall.cancel(), preventing spurious error events on intentional shutdown (same outcome as .NET'scatch when StatusCode == Cancelledfilter, without needing to inspect the error type)subjectparameter added and threaded through fromsubscribe()for use in log messagesTests: 4 new cases
subscribe registers error and end listeners on callunsubscribe removes error and end listeners before cancellingsubscription emits error when call emits errorsubscription emits error when call emits end