Skip to content

AddMemoryStreams in ISiloBuilder.UseSignalR can yield duplicate key #158

@hendrikdevloed

Description

@hendrikdevloed

The two other cases are covered by a try...catch in case the user overrode the default, but should the AddMemoryStreams also be conditional in case a SIGNALR_ORLEANS_STREAM_PROVIDER was already registered?

I registered the same memory stream in my startup code but I got an error later on (during app.Run) about a duplicate key. I can imagine the same would happen when trying to register a persistent stream type.

https://github.com/OrleansContrib/SignalR.Orleans/blob/ad56e34e7c177b5be4ae7d3afee43f324478951f/src/SignalR.Orleans/Hosting/ISiloBuilderExtensions.cs#L36C26-L36C26

To keep using the nuget code, a workaround for my particular case is here https://pastebin.com/BetpuqXM but that's not a fundamental solution.

Should there be an if clause around the AddMemoryStreams to check for the presence of a SIGNALR_ORLEANS_STREAM_PROVIDER before registering the memory stream? Try...catch doesn't seem to be a solution because it doesn't generate an exception immediately, in contrast to the previous calls.

(On a related note, should the two try..catch use some lighter non-exception-based mechanism to check for the presence instead?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions