Skip to content
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

[release/8.0][browser][http] mute JS exceptions about network errors + HEAD verb #113271

Conversation

pavelsavara
Copy link
Member

@pavelsavara pavelsavara commented Mar 7, 2025

Backport of #113014 to release/8.0 with modifications for Net8

Customer Impact

  1. In browser HTTP client we subscribe for rejected promises in order to suppress unhandled rejection of AbortError when we issue the abort. The current handler also handles other network errors and aborts the whole program, which is not what it should do. Instead the network error should be propagated to managed HTTP client code.

  2. in Firefox when the verb is HEAD, the body is null. We should not fail because of that.

  • Customer reported
  • Found internally

Contributes to #112172
Fixes #111992

Regression

  • Yes
  • No

Testing

Automated tests.

Risk

Low

Both issues are only triggered when user enabled streaming responses. That's opt-in feature in Net8.

@pavelsavara pavelsavara added Servicing-consider Issue for next servicing release review arch-wasm WebAssembly architecture area-System.Net.Http os-browser Browser variant of arch-wasm labels Mar 7, 2025
@pavelsavara pavelsavara added this to the 8.0.x milestone Mar 7, 2025
@pavelsavara pavelsavara requested a review from maraf March 7, 2025 18:42
@pavelsavara pavelsavara self-assigned this Mar 7, 2025
Copy link
Contributor

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

@pavelsavara
Copy link
Member Author

cc @campersau

@hectorm-bmg
Copy link

@pavelsavara Thank you! I'll let you know how it works in the next release. BTW, do you guys set tickets to closed when they are released? or when should I expect the next release to happen?

@pavelsavara
Copy link
Member Author

Tests passed on chrome, log
image

@pavelsavara pavelsavara marked this pull request as ready for review March 8, 2025 15:40
@Copilot Copilot bot review requested due to automatic review settings March 8, 2025 15:40
@pavelsavara pavelsavara requested review from lewing and kg as code owners March 8, 2025 15:40
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.

PR Overview

This PR backports fixes to address unintended exception propagation in the browser HTTP client and to handle HEAD verb responses correctly in Firefox within Net8. Key changes include adding new tests for multiple HTTP methods including abort scenarios, updating the EchoHandler to handle delays and aborts appropriately, and modifying the wasm HTTP request handling to mute specific unhandled rejections.

Reviewed Changes

File Description
src/libraries/Common/tests/System/Net/Http/ResponseStreamTest.cs Added new test cases covering different HTTP methods and abort scenarios for streaming responses.
src/libraries/Common/tests/System/Net/Prerequisites/NetCoreServer/Handlers/EchoHandler.cs Updated the echo handler to incorporate delay, buffering control, and proper handling of the HEAD method and abort scenarios.
src/mono/wasm/runtime/http.ts Modified the HTTP handling logic to improve the muting of unhandled promise rejections by refactoring error handling in abort scenarios.

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

src/libraries/Common/tests/System/Net/Prerequisites/NetCoreServer/Handlers/EchoHandler.cs:76

  • [nitpick] Consider using a pre-defined constant (such as HttpMethods.Head) instead of the string literal "HEAD" to maintain consistency with other HTTP method checks.
if(context.Request.Method == "HEAD")

@pavelsavara
Copy link
Member Author

@pavelsavara Thank you! I'll let you know how it works in the next release.

@hectorm-bmg

It should land in Net 10 preview3 nightly in next few days. It would be awesome if you can try to use it to validate the fix and report back. That would decrease risk for the Net8 patch.

https://aka.ms/dotnet/10.0.1xx/daily/dotnet-sdk-win-x64.zip

BTW, do you guys set tickets to closed when they are released? or when should I expect the next release to happen?

I think this will go out in 8.0.15 in April.

@carlossanlop
Copy link
Member

@pavelsavara @lewing Today is code complete for the April Release. If you want this fix included in this release, please get it approved by Tactics and merge it before 4pm PT.

@pavelsavara pavelsavara added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Mar 11, 2025
@pavelsavara
Copy link
Member Author

/ba-g CI failures are unrelated

@pavelsavara pavelsavara merged commit 5a1fc27 into dotnet:release/8.0-staging Mar 17, 2025
125 of 135 checks passed
@pavelsavara pavelsavara deleted the backport/pr-113014-to-release/8.0-staging branch March 17, 2025 11:08
@hectorm-bmg
Copy link

@pavelsavara Thank you! I'll let you know how it works in the next release.

@hectorm-bmg

It should land in Net 10 preview3 nightly in next few days. It would be awesome if you can try to use it to validate the fix and report back. That would decrease risk for the Net8 patch.

https://aka.ms/dotnet/10.0.1xx/daily/dotnet-sdk-win-x64.zip

BTW, do you guys set tickets to closed when they are released? or when should I expect the next release to happen?

I think this will go out in 8.0.15 in April.

@pavelsavara I downloaded the dotnet sdk, however, it looks like I need to have visual studio 17.16.
The current Visual Studio version does not support targeting .NET 10.0. Either target .NET 9.0 or lower, or use Visual Studio version 17.16 or higher
How do I get that version of Visual Studio?
I tried getting visual studio preview but the latest version is 17.14.

@pavelsavara
Copy link
Member Author

@pavelsavara I downloaded the dotnet sdk, however, it looks like I need to have visual studio 17.16.

@hectorm-bmg I don't know much about VS versions, sorry. Does your repro build with dotnet run or dotnet publish on command line ?

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.Net.Http os-browser Browser variant of arch-wasm Servicing-approved Approved for servicing release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants