Skip to content

[Feature]: Expose an event for failed web requests to the host application #5608

@awolbach

Description

@awolbach

Describe the feature/enhancement you need

Mainly for diagnostic purposes, it would be helpful to expose an event to the host application when a web request fails due to a network error. If I'm understanding the Chromium code correctly, I think this is typically done by setting an OnRequestError override in the implementation's ProxyingURLLoaderFactory::InProgressRequest class (this seems to be what Electron does for its webRequest.onErrorOccurred event, for example). Then when something unexpectedly goes wrong at the network layer we can easily log it.

I checked and am not seeing a CoreWebView2.WebResourceResponseReceived or a CoreWebView2.NavigationCompleted event raised when the system is preparing to hibernate and a web request is sent out and fails, so I don't think there's a way to get this from the existing WebView2 APIs.

The scenario/use case where you would use this feature

System is suspending and cuts network access, DNS problems, the request is aborted somehow, etc.

How important is this request to you?

Nice to have. There are other ways to tackle this, but having official API support would be beneficial.

Suggested implementation

How about a CoreWebView2.WebResourceRequestFailed event:

public event EventHandler<Microsoft.Web.WebView2.Core.CoreWebView2WebResourceRequestFailedEventArgs> WebResourceRequestFailed;

Where a new CoreWebView2WebResourceRequestFailedEventArgs class contains properties for:

Request - the original CoreWebView2WebResourceRequest from the WebResourceRequested event
ResourceContext - the CoreWebView2WebResourceContext for the web request
WebErrorStatus - the CoreWebView2WebErrorStatus error code

Or instead of reusing the NavigationCompleted event's CoreWebView2WebErrorStatus enum, just expose the error name as a string in the way other CEF implementations do.

What does your app do? Is there a pending deadline for this request?

No response

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions