Skip to content

Conversation

@pavelsavara
Copy link
Member

@pavelsavara pavelsavara commented Jan 20, 2026

  • ported HTTP and WS JS clients from Mono
  • add HTTP and WS tests into CoreCLR library smoke test
  • rename closeStatus, closeStatusDescription on the JS webSocket controller
  • fix marshalTaskToCs for case with null promise
  • add runBackgroundTimers and rename abortBackgroundTimers
  • add abortInteropTimers and preventTimerThrottling

Fixes #120216

@pavelsavara pavelsavara added this to the 11.0.0 milestone Jan 20, 2026
@pavelsavara pavelsavara requested a review from maraf January 20, 2026 19:48
@pavelsavara pavelsavara self-assigned this Jan 20, 2026
@pavelsavara pavelsavara added arch-wasm WebAssembly architecture area-System.Runtime.InteropServices.JavaScript os-browser Browser variant of arch-wasm labels Jan 20, 2026
@pavelsavara pavelsavara marked this pull request as ready for review January 21, 2026 19:34
@pavelsavara pavelsavara requested a review from lewing as a code owner January 21, 2026 19:34
Copilot AI review requested due to automatic review settings January 21, 2026 19:34
Copy link
Contributor

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 pull request ports HTTP and WebSocket JavaScript client implementations from Mono to CoreCLR, enabling browser-based networking functionality for CoreCLR WASM applications.

Changes:

  • Ported WebSocket and HTTP client implementations from Mono's TypeScript codebase to CoreCLR's JavaScript native layer
  • Added timer throttling prevention and background timer management for WebSocket connections
  • Fixed null promise handling in marshalTaskToCs to prevent runtime errors
  • Renamed WebSocket close status properties from close_status/close_status_description to closeStatus/closeStatusDescription for JavaScript naming conventions
  • Added HTTP and WebSocket tests to CoreCLR browser smoke tests
  • Reorganized timer cleanup logic in the exit flow

Reviewed changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
web-socket.ts Complete WebSocket client implementation ported from Mono with connection management, message buffering, and error handling
http.ts HTTP client implementation with support for streaming requests/responses and fetch API wrapper
queue.ts Generic queue data structure for managing WebSocket event and promise queues
scheduling.ts Browser timer throttling prevention mechanism for Chromium-based browsers and timer cleanup
utils.ts Added relaxed UTF-8 to string decoder for WebSocket text messages
marshal-to-cs.ts Fixed bug where null promises would cause runtime errors by adding early return
marshal.ts Added browser detection flags for Chromium and Firefox
index.ts Registered new HTTP and WebSocket exports for C# interop
host.ts Renamed abortTimers to abortBackgroundTimers and added runBackgroundTimers
exit.ts Reorganized timer cleanup to call abortInteropTimers and abortBackgroundTimers earlier in exit flow
BrowserInterop.cs Updated to use renamed WebSocket close status properties
web-socket.ts (Mono) Renamed WebSocket properties to match JavaScript conventions
tests.proj Added HTTP and WebSocket tests to CoreCLR browser smoke tests
System.Runtime.InteropServices.JavaScript.Tests.csproj Enabled HTTP tests for CoreCLR and XunitShowProgress for test tracking
System.Net.WebSockets.Client.Tests.csproj Added XunitShowProgress for CoreCLR test tracking
System.Net.Http.Functional.Tests.csproj Updated XunitShowProgress condition from managed threads to runtime flavor
CMakeLists.txt Added new TypeScript source files to build configuration
exchange.ts Updated type definitions for new timer and interop functions
cross-module/index.ts Updated export table mappings for new functions
libSystem.Native.Browser.footer.js Reformatted dependency array for readability
scheduling.ts (Browser native) Removed trailing newline

pavelsavara and others added 3 commits January 21, 2026 20:51
…ve/interop/web-socket.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ve/interop/queue.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ve/interop/queue.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
# Conflicts:
#	src/libraries/tests.proj
Copy link
Member

@javiercn javiercn left a comment

Choose a reason for hiding this comment

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

Looks good to me! Just a couple small questions/nits. My understanding is that we already have all the tests for this and we are just enabling them with this new support.

@pavelsavara
Copy link
Member Author

Just a couple small questions/nits.

I will process the nits on next PR

My understanding is that we already have all the tests for this and we are just enabling them with this new support.

This is porting it existing codebase to new place (and camelCase) and using existing tests untouched.
Below are logs from it running on CoreCLR

Log

[21:29:12] info: Finished:    System.Net.WebSockets.Client.Tests.dll
[21:29:12] info: Stored /root/helix/work/workitem/uploads/xharness-output/testResults.xml results 120267 bytes
[21:29:12] info: Finished uploading 120267 bytes of RESULTXML
[21:29:12] info: Xml file was written to the provided writer.
[21:29:12] info: 
[21:29:12] info: === TEST EXECUTION SUMMARY ===
[21:29:12] info: Tests run: 315 Passed: 315 Inconclusive: 0 Failed: 0 Ignored: 0 Skipped: 0
[21:29:12] info: 
[21:29:12] info: test-main.js exiting WasmTestRunner.dll System.Net.WebSockets.Client.Tests.dll after 2.805083333333333 minutes with result 0 and linear memory 193331200 bytes

Log

[21:28:44] info: Finished:    System.Net.Http.Functional.Tests.dll
[21:28:44] info: Stored /root/helix/work/workitem/uploads/xharness-output/testResults.xml results 433179 bytes
[21:28:44] info: Finished uploading 433179 bytes of RESULTXML
[21:28:44] info: Xml file was written to the provided writer.
[21:28:44] info: 
[21:28:44] info: === TEST EXECUTION SUMMARY ===
[21:28:44] info: Tests run: 901 Passed: 781 Inconclusive: 0 Failed: 0 Ignored: 0 Skipped: 120
[21:28:44] info: 
[21:28:44] info: test-main.js exiting WasmTestRunner.dll System.Net.Http.Functional.Tests.dll after 2.1928833333333335 minutes with result 0 and linear memory 334102528 bytes

@pavelsavara pavelsavara merged commit 0c78a5d into dotnet:main Jan 23, 2026
162 of 163 checks passed
@pavelsavara pavelsavara deleted the browser_ws_http branch January 23, 2026 12:19
pavelsavara added a commit to pavelsavara/runtime that referenced this pull request Jan 23, 2026
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.

[browser][coreclr] HTTP client

2 participants