-
-
Notifications
You must be signed in to change notification settings - Fork 844
Better exception handling for @ui.page #5139
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
base: main
Are you sure you want to change the base?
Conversation
(asyncio.wait does not raise TimeoutError)
because websocket is not supported by chrome in this case
which is default when Chrome prerenders
by increasing page response timeout generously
Still seven tests are failing...
|
Somewhere along the commit history of #4538 there's provision for sending the error to the browser client in the case that the page was returned to the browser, then it errored out, addressing the above by adding a new function. It may be helpful if you take example of that, though to be honest that is a pretty rough PR in the beginning so your mileage may vary. |
otherwise python 3.9 will use asyncio.Event within Client from wrong event loop
to do special exception handling
#5116 merged, so we close this one? Or there are still stuff of value in this PR? (on mobile can't check) |
I think there are still valuable parts in this PR. But I've been to busy to look at it. Let's keep it open for a while longer. |
Motivation
While working on #5116, I saw some strange behaviours and inconsistencies when pages raise exceptions. Here are some examples:
check_for_late_return_value
simply accessedtask.result()
which itself raises an exception... but that complicates the stack tracecreate_error_page
simply raisede
if no page exception handler was registered -- leading to complicated stacktracewait_for_result
always created an error page response on exception; even when the response was already send to the browsernot client.sub_pages_router._can_resolve_full_path(client)
, a error page was returned and not a responseImplementation
NOTE: this PR is based on #5116 to avoid merge conflicts -- ideally we can merge #5116 to 3.0 before this one and then change target branch
What has been done so far:
shorter stacktrace for page builders
Consider raising an exception after
client.connected()
:Before this PR the stacktrace is
By checking for
task.cancelled()
andtask.exception()
incheck_for_late_return_value
its now a bit cleaner:Progress