Skip to content

NullReferenceException in SignalR's DefaultHubDispatcher #25612

Closed

Description

@imb590

DefaultHubDispatcher calls DisposeAsync on a null reference if IServiceScopeFactory.CreateScope throws an exception here, so NullReferenceException is thrown from the finally block, overwriting the original exception. This happens when the application is stopping and dispatcher methods are called after IServiceProvider is disposed.

Activity

  1. BrennanConroy commented on Sep 4, 2020

    @BrennanConroy
    Member

    I'm guessing your app is being shutdown ungracefully? If so, we can't really guarantee cleanup to be clean either.

    We can do a little cleanup here and move the CreateScope call outside of the try catch so the original exception is preserved.

    If you have a long running hub method that isn't observing connection close's (when the app shuts down) then that could cause this issue as well. Either using ApplicationStopping, or Context.ConnectionAborted.

  2. added this to the Backlog milestone on Sep 4, 2020
  3. imb590 commented on Sep 7, 2020

    @imb590
    Author

    The shutdown is not graceful, but it is still reasonable to expect an exception from a disposed IServiceProvider in this case, not a NRE, isn't it?

  4. davidfowl commented on Oct 2, 2020

    @davidfowl
    Member

    Yes absolutely it just makes it a lower priority.

  5. added
    affected-very-fewThis issue impacts very few customers
    bugThis issue describes a behavior which is not expected - a bug.
    on Nov 9, 2020
  6. ghost locked as resolved and limited conversation to collaborators on Mar 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    affected-very-fewThis issue impacts very few customersarea-signalrIncludes: SignalR clients and serversbugThis issue describes a behavior which is not expected - a bug.severity-nice-to-haveThis label is used by an internal tool

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions