Set SignalR WebSocketFactory for all environments#65359
Set SignalR WebSocketFactory for all environments#65359BekAllaev wants to merge 1 commit intodotnet:mainfrom
Conversation
Previously, WebSocketFactory was only assigned for non-browser environments. This change moves the assignment outside the browser check, ensuring WebSocketFactory is consistently set regardless of the environment.
|
Thanks for your PR, @@BekAllaev. Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
There was a problem hiding this comment.
Pull request overview
This PR updates the SignalR C# client’s HttpConnectionFactory shallow-copy logic so HttpConnectionOptions.WebSocketFactory is preserved for browser environments as well, instead of being dropped behind a !OperatingSystem.IsBrowser() guard.
Changes:
- Always assign
WebSocketFactorywhen shallow-copyingHttpConnectionOptions. - Remove the browser-only omission of
WebSocketFactoryfrom the non-browser conditional block.
| ApplicationMaxBufferSize = options.ApplicationMaxBufferSize, | ||
| TransportMaxBufferSize = options.TransportMaxBufferSize, | ||
| UseStatefulReconnect = options.UseStatefulReconnect, | ||
| WebSocketFactory = options.WebSocketFactory, |
There was a problem hiding this comment.
The new behavior (copying WebSocketFactory even when OperatingSystem.IsBrowser() is true) isn’t covered by existing tests. Current unit tests for ShallowCopyHttpConnectionOptions only run on non-browser runtimes and don’t validate the browser-specific path, so a regression here could go unnoticed. Consider adding a test that runs under a browser/WASM target (or another automated browser-runtime test) to assert that WebSocketFactory flows through the shallow copy on browser platforms.
Set SignalR WebSocketFactory for all environments
This pull request makes a minor adjustment to the handling of the
WebSocketFactoryproperty in theHttpConnectionFactoryclass. The change ensures thatWebSocketFactoryis always set in the shallow copy ofHttpConnectionOptions, regardless of the operating system.Summary of the changes:
Always assign
WebSocketFactorywhen creating a shallow copy ofHttpConnectionOptions, not only on non-browser platforms. Previously it was only assigned inside the!OperatingSystem.IsBrowser()block.Description
Fixes #63742