Skip to content

Rusi transport emit subscription errors#51

Merged
oncicaradupopovici merged 3 commits into
mainfrom
rusi-transport-emit-subscription-errors
May 18, 2026
Merged

Rusi transport emit subscription errors#51
oncicaradupopovici merged 3 commits into
mainfrom
rusi-transport-emit-subscription-errors

Conversation

@oncicaradupopovici
Copy link
Copy Markdown
Contributor

Problem

When the rusi sidecar returns subscription-level stream errors (e.g. stan: subscribe request timeout), the gRPC channel remains READY so no connection-level error fires. The rusi transport only logged these errors and never forwarded them to the Subscription EventEmitter, causing subscribers to silently hang with no possibility of recovery.

Solution

Rewrite rusiSubscription to forward call stream 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)

  • Added named onError handler: logs the error and calls sub.emit('error', e)
  • Added named onEnd handler: synthesises an Error and calls sub.emit('error', err) — a stream ending unexpectedly is treated as an error
  • unsubscribe() removes both listeners via removeListener before calling call.cancel(), preventing spurious error events on intentional shutdown (same outcome as .NET's catch when StatusCode == Cancelled filter, without needing to inspect the error type)
  • subject parameter added and threaded through from subscribe() for use in log messages

Tests: 4 new cases

  • subscribe registers error and end listeners on call
  • unsubscribe removes error and end listeners before cancelling
  • subscription emits error when call emits error
  • subscription emits error when call emits end

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 18, 2026

🦋 Changeset detected

Latest commit: e3b6b70

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@totalsoft/message-bus Patch

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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 call stream error events to the subscription (sub.emit('error', e)).
  • Treat unexpected end of 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.

Comment thread packages/message-bus/src/transport/rusi/index.ts
Comment thread packages/message-bus/src/transport/rusi/index.ts
Comment thread packages/message-bus/__tests__/transport/rusi.test.ts
…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 fraliv13 self-requested a review May 18, 2026 11:32
@oncicaradupopovici oncicaradupopovici merged commit 34f640b into main May 18, 2026
1 check passed
@oncicaradupopovici oncicaradupopovici deleted the rusi-transport-emit-subscription-errors branch May 18, 2026 14:49
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.

4 participants