Skip to content

[browser][ws] WebSocket works differently depending on if we look up its state or not #99545

@ilonatommy

Description

@ilonatommy

Test from here: https://github.com/dotnet/runtime/pull/99413/files#diff-833e4f96268680f6e3161446593f03844000ff0dafd163add5b0f856d2e2360f

If we do:
connect wb, server sends a message and closes
scenario 1): Client waits some time, calls ReceiveAsync -> client receives the buffered message, no exception because managed code did not update the ws's state.
scenario 2): Client waits some time, checks the server's state by accessing WebSocket.State, calls ReceiveAsync -> exception, Unhandled exception rendering component: The WebSocket is in an invalid state ('Closed') for this operation. Valid states are: 'Open, CloseSent' because by accessing State property we made the closing state propagate to C#.

Internally we don't use State but FastState. Only getting State triggers JS interop.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions