[HybridWebView] Bubble up exceptions in JS into .NET#27129
Merged
mattleibow merged 5 commits intomainfrom Jan 23, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Copilot reviewed 5 out of 9 changed files in this pull request and generated no comments.
Files not reviewed (4)
- src/Controls/tests/DeviceTests/Resources/Raw/HybridTestRoot/index.html: Language not supported
- src/Controls/src/Core/Hosting/AppHostBuilderExtensions.cs: Evaluated as low risk
- src/Controls/tests/DeviceTests/Elements/HybridWebView/HybridWebViewTests.cs: Evaluated as low risk
- src/Core/src/Handlers/HybridWebView/HybridWebViewTaskManager.cs: Evaluated as low risk
Comments suppressed due to low confidence (2)
src/Core/src/Handlers/HybridWebView/HybridWebViewHandler.cs:115
- Ensure that the new exception handling logic for '__InvokeJavaScriptFailed' is covered by tests.
case "__InvokeJavaScriptFailed":
src/Core/src/Handlers/HybridWebView/HybridWebViewTask.cs:5
- [nitpick] The term 'TaskId' is clear, but ensure that all new symbols follow the same clarity and consistency.
internal record struct HybridWebViewTask(string TaskId, TaskCompletionSource<string?> TaskCompletionSource);
mattleibow
commented
Jan 14, 2025
src/Controls/tests/DeviceTests/Resources/Raw/HybridTestRoot/scripts/HybridWebView.js
Show resolved
Hide resolved
80447ea to
94d0e3b
Compare
Eilon
previously approved these changes
Jan 15, 2025
Contributor
Eilon
left a comment
There was a problem hiding this comment.
The code and tests look good to me. Please note my 2 comments.
src/Controls/tests/DeviceTests/Resources/Raw/HybridTestRoot/scripts/HybridWebView.js
Show resolved
Hide resolved
Member
Author
|
/rebase |
94d0e3b to
175c8a3
Compare
Member
Author
|
This should be behind a flag. I need to create an issue for net10 to make the switch by default to throw. |
5b4193f to
1e26742
Compare
1e26742 to
628187f
Compare
tj-devel709
approved these changes
Jan 22, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of Change
Previously an exception in JS would just fail to return to .NET, leaving the tasks unfinished.
This PR makes sure to catch the exception in JS and then send it back to .NET where it is re-thrown as a .NET exception.
There is additional work to remove the task manager from the handler definition and move the logic into a new service that is registered. This will allow for better testing and/or a new handler that does not need to also use the internal interface.
By default there is no behavior change, but you can enable this AppContext Switch with one line of code in your app's MauiProgram.cs:
Issues Fixed
Fixes #27097