MicrosoftEdge / MicrosoftEdge/WebView2Feedback

[Problem/Bug]: Exception 0xFFFF8300 is raised in await e.Response.GetContentAsync()

Open
#4,663 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
PowerShell
Stars
526
Forks
67
PR merge metrics
No merged PRs in 30d

Description

What happened?

When I paste WebView2 into a form and request Navigate, in order to trace all the interaction with the other host, I use WebResourceResponseReceived to get the data received in await, but Await e.Response. GetContentAsync() may raise an exception. Is there any way to deal with this?
The operating environment is as follows (developed in VB.NET)
Windows10
NET Framework 4.8
WebView2 Runtime 126.0.2592.87
Microsoft.Web.WebView2 1.0.2592.61

`
Private Async Sub WebResourceResponseReceived(sender As Object, e As CoreWebView2WebResourceResponseReceivedEventArgs)

    Dim objUri As Uri
    Dim strContentType As String
    Try
        If e.Response.StatusCode >= 300 And e.Response.StatusCode <= 399 Then Exit Sub
        strContentType = Nothing
        For Each objHeader In e.Response.Headers
            If objHeader.Key.Equals("Content-Type", StringComparison.OrdinalIgnoreCase) Then
                strContentType = objHeader.Value
                Exit For
            End If
        Next
        Try
            objUri = New Uri(e.Request.Uri)
            If objUri.Scheme <> "https" Then Exit Sub
        Catch ex As Exception
            Exit Sub
        End Try
        If strContentType IsNot Nothing Then
            If Regex.IsMatch(strContentType, "(application/json|text/html|text/xml|text/plan)", RegexOptions.IgnoreCase) Then
                Using objStream = Await e.Response.GetContentAsync()
                    Using objReader As New StreamReader(objStream)
                        Await objReader.ReadToEndAsync()
                    End Using
                End Using
            End If
        End If
    Catch ex As Exception
        Debug.Print("●" & e.Request.Uri)
        Debug.Print(e.Response.StatusCode)
        Debug.Print("■" & ex.Message)
    End Try
End Sub

`
The error that occurs is as follows
Exception thrown: 'System.Runtime.InteropServices.COMException' (in mscorlib.dll)

Importance

Blocking. My app's basic functions are not working due to this issue.

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

126.0.2592.87

SDK Version

No response

Framework

Winforms

Operating System

Windows 10

OS Version

No response

Repro steps

The following processes occur with high frequency (not always)
WebView21.CoreWebView2.Navigate("https://ja.aliexpress.com/item/1005005239744204.html")

Repros in Edge Browser

No, issue does not reproduce in the corresponding Edge version

Regression

No, this never worked

Last working version (if regression)

No response

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the WebResourceResponseReceived handler and its await e.Response.GetContentAsync() call, then reproduce the failure with Navigate("https://ja.aliexpress.com/item/1005005239744204.html") under the listed WebView2 versions. Compare the response status, headers, URI, and exception occurrence; done means the intermittent COMException is explained and a verified handling or fix is identified.

Written by the indexing model from the issue text.

Assessment

Tech stack
visualbasic
Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.