Skip to content

RG-T135 SignalR Fix - #535

Merged
ucswift merged 1 commit into
masterfrom
develop
Sep 28, 2026
Merged

ucswift merged 1 commit into
masterfrom
develop

Conversation

@ucswift

@ucswift ucswift commented Sep 28, 2026 •

Copy link
Copy Markdown
Member

Summary

Fixes SignalR operations that continue executing after a client connection has closed.

Changes

  • Added connection-aborted checks before modifying SignalR groups or sending connection notifications in:
    • Eventing hubs
    • Services Eventing hub
    • Chat hub
  • Prevented group removal attempts for closed connections.
  • Updated geolocation connection tracking to:
    • Accept the connection’s cancellation token.
    • Remove connections that close while an in-flight hub call is registering them.
    • Skip subscription and group synchronization when tracking detects a closed connection.
  • Added regression coverage for:
    • Group-changing calls on open connections.
    • Group-changing calls on closed connections.
    • Geolocation calls that complete after disconnection.
    • Ensuring no stale geolocation connections or group operations remain.

This prevents SignalR and the Redis backplane from waiting for acknowledgements from connections that are no longer held by the server.

@request-info

request-info Bot commented Sep 28, 2026

Copy link
Copy Markdown

Thanks for opening this, but we'd appreciate a little more information. Could you update it with more details?

@Resgrid-Bot

Resgrid-Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ❌
Security ✅
Business Logic ❌

Access your configuration settings here.

​

@coderabbitai

coderabbitai Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: Resgrid/Core/.coderabbit.yaml

Review profile: CHILL

Plan: Essentials

Run ID: a97054ef-f1e0-4967-b3eb-734cb7db0d67

📥 Commits

Reviewing files that changed from the base of the PR and between fc8e1e2 and 9324159.

⛔ Files ignored due to path filters (2)
  • Tests/Resgrid.Tests/Web/Eventing/ClosedConnectionHubTests.cs is excluded by !**/Tests/**
  • Tests/Resgrid.Tests/Web/Eventing/GeolocationVisibilityTests.cs is excluded by !**/Tests/**
📒 Files selected for processing (6)
  • Web/Resgrid.Web.Eventing/Hubs/ChatHub.cs
  • Web/Resgrid.Web.Eventing/Hubs/EventingHub.cs
  • Web/Resgrid.Web.Eventing/Hubs/GeolocationHub.cs
  • Web/Resgrid.Web.Eventing/Services/GeolocationConnectionTracker.cs
  • Web/Resgrid.Web.Services/Hubs/EventingHub.cs
  • Web/Resgrid.Web.Services/Resgrid.Web.Services.xml

Included review availability: This review used your included allowance. 2 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 3 reviews per hour. Your free on-demand review promotion remains active until October 9, 2026 at 6:00 PM UTC.


📝 Walkthrough

Walkthrough

The hubs now check connection cancellation before selected group operations and notifications. Geolocation tracking accepts the connection-aborted token and can return null, causing its callers to stop before further subscription work.

Changes

Connection cancellation handling

Layer / File(s) Summary
Group operations in eventing hubs
Web/Resgrid.Web.Eventing/Hubs/ChatHub.cs, Web/Resgrid.Web.Eventing/Hubs/EventingHub.cs, Web/Resgrid.Web.Services/Hubs/EventingHub.cs, Web/Resgrid.Web.Services/Resgrid.Web.Services.xml
The hubs check connection status before selected group joins, removals, and connection notifications. The services hub XML documentation describes its connection-close check.
Cancellation-aware geolocation tracking
Web/Resgrid.Web.Eventing/Services/GeolocationConnectionTracker.cs, Web/Resgrid.Web.Eventing/Hubs/GeolocationHub.cs
The tracker accepts the connection-aborted token and returns null if cancellation is requested after tracking. The geolocation hub stops before subscriptions, group synchronization, or success notifications when tracking returns null.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 93241

The identified group-operation concern does not warrant a change, and no actionable issue introduced by this PR remains. The change is mergeable after normal checks.

🚥 Pre-merge checks | ✅ 3 | ❌ 1 | ❓ 1

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 21 functions across 5 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title identifies SignalR as the affected area, but “Fix” does not describe the main change: handling aborted connections before SignalR group operations. Use a specific title such as “RG-T135 Handle aborted SignalR connections”.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 21 functions across 5 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Comment @coderabbitai help to get the list of available commands.

public async Task Open_connection_changes_groups(Func<Harness, Task> arrange, Func<Harness, Task> act)
{
var harness = new Harness();
await arrange(harness);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Kody Rules high

Unhandled task rejection in await arrange(harness) prevents arrangement failures from being reported with test context. Catch Exception and call Assert.Fail with the failure details in Tests/Resgrid.Tests/Web/Eventing/ClosedConnectionHubTests.cs:57, :66, and :70, and Tests/Resgrid.Tests/Web/Eventing/GeolocationVisibilityTests.cs:192 and :194.

Kody rule violation: Handle async operations with proper error handling

try { await arrange(harness); } catch (Exception exception) { Assert.Fail($"Arrange failed: {exception}"); }
Prompt for LLM

File Tests/Resgrid.Tests/Web/Eventing/ClosedConnectionHubTests.cs:

Line 54:

Unhandled task rejection in `await arrange(harness)` prevents arrangement failures from being reported with test context. Catch `Exception` and call `Assert.Fail` with the failure details in `Tests/Resgrid.Tests/Web/Eventing/ClosedConnectionHubTests.cs:57`, `:66`, and `:70`, and `Tests/Resgrid.Tests/Web/Eventing/GeolocationVisibilityTests.cs:192` and `:194`.

Suggested Code:

try { await arrange(harness); } catch (Exception exception) { Assert.Fail($"Arrange failed: {exception}"); }

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​


public sealed class Harness
{
private readonly CancellationTokenSource _connectionAborted = new CancellationTokenSource();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Kody Rules high

Resource leak occurs because the CancellationTokenSource stored in _connectionAborted remains undisposed after the test completes. Implement IDisposable on Harness and dispose _connectionAborted during teardown.

Kody rule violation: Use using statements for disposable resources

private readonly CancellationTokenSource _connectionAborted = new CancellationTokenSource();

public void Dispose() => _connectionAborted.Dispose();
Prompt for LLM

File Tests/Resgrid.Tests/Web/Eventing/ClosedConnectionHubTests.cs:

Line 80:

Resource leak occurs because the `CancellationTokenSource` stored in `_connectionAborted` remains undisposed after the test completes. Implement `IDisposable` on `Harness` and dispose `_connectionAborted` during teardown.

Suggested Code:

private readonly CancellationTokenSource _connectionAborted = new CancellationTokenSource();

public void Dispose() => _connectionAborted.Dispose();

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​

@ucswift

ucswift commented Sep 28, 2026

Copy link
Copy Markdown
Member Author

Approve

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This PR is approved.

@ucswift
ucswift merged commit 0bdf2c0 into master Sep 28, 2026
18 of 19 checks passed
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.

2 participants