Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

PyScript components become unresponsive on exceptions #1276

Open
Labels
priority-2-moderateShould be resolved on a reasonable timeline.

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

No one assigned

    Labels

    priority-2-moderateShould be resolved on a reasonable timeline.

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /