-
-
Notifications
You must be signed in to change notification settings - Fork 328
PyScript components become unresponsive on exceptions #1276
Open
Description
Current Situation
If an exception is thrown in the component body of a PyScript component, the component's become unresponsive. This can be demonstrated by using the following pyscript component
from reactpy import component, hooks, html @component def root(): count, set_count = hooks.use_state(0) def increment(event): set_count(count + 1) if count == 5: raise ValueError("This error both breaks this component's rendering stack, and does not hide the component.") return html.div( html.button({"onClick": increment}, "Increment"), html.p(f"Count: {count}"), )
This is strange since layout.py defines that components should hide themselves when exceptions occur, and that's clearly not happening.
Something notable is that this issue only occurs if the exception occurs in the root component. The expected behavior will occur if the exception happens in any child components. For example...
@component def root(): return html.fragment( counter(), counter(), ) @component def counter(): count, set_count = hooks.use_state(0) def increment(event): set_count(count + 1) if count == 5: raise ValueError("This is an error 2") return html.div( html.button({"onClick": increment}, "Increment"), html.p(f"PyScript Count: {count}"), )
Proposed Actions
Figure out why this behavior exists. Perhaps this behavior also exists in server-side components and we just haven't noticed until now?
Metadata
Metadata
Assignees
Type
Fields
Give feedbackNo fields configured for Bug.