Skip to content

Conversation

pavelsavara
Copy link
Member

@pavelsavara pavelsavara commented Aug 19, 2025

  • delay setting close to receive_status_ptr to not conflict with on-message event
  • fix status for wasm_ws_close_sent

Fixes #117964

…essage event

- fix status for wasm_ws_close_sent
@pavelsavara pavelsavara added this to the 10.0.0 milestone Aug 19, 2025
@pavelsavara pavelsavara self-assigned this Aug 19, 2025
@pavelsavara pavelsavara added arch-wasm WebAssembly architecture area-System.Runtime.InteropServices.JavaScript os-browser Browser variant of arch-wasm labels Aug 19, 2025
@pavelsavara pavelsavara marked this pull request as ready for review August 20, 2025 07:52
@Copilot Copilot AI review requested due to automatic review settings August 20, 2025 07:52
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a race condition in WebSocket handling between message and close events by introducing proper timing control and status management.

Key changes:

  • Delays the setting of close status to prevent conflicts with on-message events using setTimeout
  • Fixes the WebSocket state logic to properly return CLOSING status when a close has been sent

@pavelsavara pavelsavara merged commit 3376cbd into dotnet:main Aug 20, 2025
37 checks passed
@pavelsavara pavelsavara deleted the browser_ws_close_race branch August 20, 2025 07:54
@pavelsavara
Copy link
Member Author

/backport to release/10.0

Copy link
Contributor

Started backporting to release/10.0: https://github.com/dotnet/runtime/actions/runs/17233378372

@pavelsavara
Copy link
Member Author

It didn't help, it's still happening in #117964

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-wasm WebAssembly architecture area-System.Runtime.InteropServices.JavaScript os-browser Browser variant of arch-wasm
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[wasm] System.Net.WebSockets.Client.Tests.InvokerCloseTest.CloseOutputAsync_ClientInitiated_CanReceive_CanClose failing with WebSocketException
2 participants