Skip to content

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

Merged
pavelsavara merged 1 commit into
dotnet:release/8.0-stagingfrom
pavelsavara:backport/pr-113014-to-release/8.0-staging
Mar 17, 2025
Merged

[release/8.0][browser][http] mute JS exceptions about network errors + HEAD verb#113271
pavelsavara merged 1 commit into
dotnet:release/8.0-stagingfrom
pavelsavara:backport/pr-113014-to-release/8.0-staging

Conversation

@pavelsavara

@pavelsavarapavelsavara commented Mar 7, 2025

Copy link
Copy Markdown
Member

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.

@pavelsavarapavelsavara 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
@pavelsavarapavelsavara added this to the 8.0.x milestone Mar 7, 2025
@pavelsavara
pavelsavara requested a review from marafMarch 7, 2025 18:42
@pavelsavarapavelsavara self-assigned this Mar 7, 2025
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

@pavelsavara

Copy link
Copy Markdown
MemberAuthor

cc @campersau

@hectorm-bmg

Copy link
Copy Markdown

@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
Copy Markdown
MemberAuthor

Tests passed on chrome, log
image

@pavelsavara
pavelsavara marked this pull request as ready for review March 8, 2025 15:40
CopilotAI review requested due to automatic review settings March 8, 2025 15:40

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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

FileDescription
src/libraries/Common/tests/System/Net/Http/ResponseStreamTest.csAdded new test cases covering different HTTP methods and abort scenarios for streaming responses.
src/libraries/Common/tests/System/Net/Prerequisites/NetCoreServer/Handlers/EchoHandler.csUpdated the echo handler to incorporate delay, buffering control, and proper handling of the HEAD method and abort scenarios.
src/mono/wasm/runtime/http.tsModified 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")

Comment threadsrc/mono/wasm/runtime/http.ts
@pavelsavara

Copy link
Copy Markdown
MemberAuthor

@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
Copy Markdown
Contributor

@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.

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

Copy link
Copy Markdown
MemberAuthor

/ba-g CI failures are unrelated

@pavelsavara
pavelsavara merged commit 5a1fc27 into dotnet:release/8.0-stagingMar 17, 2025
@pavelsavara
pavelsavara deleted the backport/pr-113014-to-release/8.0-staging branch March 17, 2025 11:08
@hectorm-bmg

Copy link
Copy Markdown

@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
Copy Markdown
MemberAuthor

@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 ?

@github-actionsgithub-actionsBot locked and limited conversation to collaborators Apr 17, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

arch-wasmWebAssembly architecturearea-System.Net.Httpos-browserBrowser variant of arch-wasmServicing-approvedApproved for servicing release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@pavelsavara@hectorm-bmg@carlossanlop@lewing