Skip to content

HttpConnectionContext.TickHeartbeat() in SignalR ticks after the context is disposed, causing runtime errors when accessing context from heartbeat handlers #60631

Open
@Amy-B-Tradition

Description

@Amy-B-Tradition

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

HubCallerContext is already disposed, its getter throws an error instead of doing anything useful (like returning a context where someone could check if it's disposed before trying to use it). When users attach OnHeartbeat handlers, I think it's fair to expect that the framework will stop calling them once the session is disposed. However, it seems like sometimes the heartbeats continue after this point, and this generates runtime errors because who wraps their property access attempts in a try/catch.

Image

Expected Behavior

Heartbeat handlers are no longer called after session dispose, or accessor does not throw an error and Context has a property that devs can check themselves.

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

No response

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-signalrIncludes: SignalR clients and servers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions