-
Notifications
You must be signed in to change notification settings - Fork 5.3k
[browser][coreCLR] HTTP and WS client implementation in JS #123400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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
marshalTaskToCsto prevent runtime errors - Renamed WebSocket close status properties from
close_status/close_status_descriptiontocloseStatus/closeStatusDescriptionfor 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 |
src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/web-socket.ts
Outdated
Show resolved
Hide resolved
src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/queue.ts
Outdated
Show resolved
Hide resolved
src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/queue.ts
Show resolved
Hide resolved
…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
javiercn
left a comment
There was a problem hiding this 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.
src/native/libs/System.Native.Browser/libSystem.Native.Browser.footer.js
Show resolved
Hide resolved
src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/http.ts
Show resolved
Hide resolved
I will process the nits on next PR
This is porting it existing codebase to new place (and camelCase) and using existing tests untouched. |
closeStatus,closeStatusDescriptionon the JS webSocket controllermarshalTaskToCsfor case with null promiserunBackgroundTimersand renameabortBackgroundTimersabortInteropTimersandpreventTimerThrottlingFixes #120216