Skip to content

Conversation

coolsoftwaretyler
Copy link
Contributor

This PR adds a new event handler to the WebView component for Android: onLoadSubResourceError, which is fired when the package receives SSL errors where the failing URL does not match the top window URL.

Currently, react-native-webview simply logs these out. But I had a use case where I needed to specifically handle these events. This patch works for my use case, and it seems reasonable other people might want something like this as well.

A simpler change might be to change TopLoadingErrorEvent to have some value indicating that failingUrl !== topWindowUrl, and just route everything through the existing handler. As a starting proposal, I chose to add a separate handler for this because I figured it was more backwards compatible. Happy to iterate on that if the project prefers a different design.

I also added a test case that points to https://badssl.com/. If you run yarn android to see the Example app and tap around, you'll see the logs coming through:

Screen.Recording.2025-08-21.at.8.32.48.PM.mov

Copy link
Collaborator

@Titozzz Titozzz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good PR

@Titozzz Titozzz merged commit 8b96334 into react-native-webview:master Aug 25, 2025
11 checks passed
react-native-community-bot pushed a commit that referenced this pull request Aug 25, 2025
# [13.16.0](v13.15.0...v13.16.0) (2025-08-25)

### Bug Fixes

* **android:** revert [#1221](#1221) setIgnoreErrFailedForThisURL ([#3831](#3831)) ([56989ca](56989ca))
* **ios:** Inline CPP operator to avoid duplicate symbols during linking ([#3830](#3830)) ([2ee4218](2ee4218))
* **types:** Make `clearCache` method required instead of optional ([#3818](#3818)) ([dd6fb80](dd6fb80))

### Features

* **android:** Add sub resource SSL error handling on Android ([#3834](#3834)) ([8b96334](8b96334))
@react-native-community-bot
Copy link
Collaborator

🎉 This PR is included in version 13.16.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

jiebenjamin90-glitch added a commit to jiebenjamin90-glitch/react-native-web-views that referenced this pull request Sep 17, 2025
# [13.16.0](react-native-webview/react-native-webview@v13.15.0...v13.16.0) (2025-08-25)

### Bug Fixes

* **android:** revert [#1221](react-native-webview/react-native-webview#1221) setIgnoreErrFailedForThisURL ([#3831](react-native-webview/react-native-webview#3831)) ([56989ca](react-native-webview/react-native-webview@56989ca))
* **ios:** Inline CPP operator to avoid duplicate symbols during linking ([#3830](react-native-webview/react-native-webview#3830)) ([2ee4218](react-native-webview/react-native-webview@2ee4218))
* **types:** Make `clearCache` method required instead of optional ([#3818](react-native-webview/react-native-webview#3818)) ([dd6fb80](react-native-webview/react-native-webview@dd6fb80))

### Features

* **android:** Add sub resource SSL error handling on Android ([#3834](react-native-webview/react-native-webview#3834)) ([8b96334](react-native-webview/react-native-webview@8b96334))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants