-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[HybridWebView] Bubble up exceptions in JS into .NET #27129
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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);
src/Controls/tests/DeviceTests/Resources/Raw/HybridTestRoot/scripts/HybridWebView.js
Show resolved
Hide resolved
80447ea
to
94d0e3b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
/rebase |
94d0e3b
to
175c8a3
Compare
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
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