Title: PyScript components become unresponsive on exceptions · Issue #1276 · reactive-python/reactpy · GitHub
Open Graph Title: PyScript components become unresponsive on exceptions · Issue #1276 · reactive-python/reactpy
X Title: PyScript components become unresponsive on exceptions · Issue #1276 · reactive-python/reactpy
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...
Open Graph 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 fr...
X 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 componen...
Opengraph URL: https://github.com/reactive-python/reactpy/issues/1276
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"PyScript components become unresponsive on exceptions","articleBody":"### Current Situation\n\nIf 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\n\n```python\nfrom reactpy import component, hooks, html\n\n@component\ndef root():\n count, set_count = hooks.use_state(0)\n\n def increment(event):\n set_count(count + 1)\n\n if count == 5:\n raise ValueError(\"This error both breaks this component's rendering stack, and does not hide the component.\")\n\n return html.div(\n html.button({\"onClick\": increment}, \"Increment\"),\n html.p(f\"Count: {count}\"),\n )\n```\n\nThis is strange since [`layout.py` defines that components should hide themselves](https://github.com/reactive-python/reactpy/blob/178fc05de7756f7402ed2ee1e990af0bdad42d9e/src/reactpy/core/layout.py#L199-L208) when exceptions occur, and that's clearly not happening.\n\nSomething 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...\n\n```python\n@component\ndef root():\n return html.fragment(\n counter(),\n counter(),\n )\n\n\n@component\ndef counter():\n count, set_count = hooks.use_state(0)\n\n def increment(event):\n set_count(count + 1)\n\n if count == 5:\n raise ValueError(\"This is an error 2\")\n\n return html.div(\n html.button({\"onClick\": increment}, \"Increment\"),\n html.p(f\"PyScript Count: {count}\"),\n )\n\n```\n\n### Proposed Actions\n\nFigure out why this behavior exists. Perhaps this behavior also exists in server-side components and we just haven't noticed until now?","author":{"url":"https://github.com/Archmonger","@type":"Person","name":"Archmonger"},"datePublished":"2025-02-12T00:03:10.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/1276/reactpy/issues/1276"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a86782a2-6c45-7401-4866-bc4f5c54cbd0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9C18:1D9B97:C143303:F932A8C:69769A2F |
| html-safe-nonce | c49bd390ce5d207c22c2dd3ad7c2263320dcbab18bac8e4beef66517387caca1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QzE4OjFEOUI5NzpDMTQzMzAzOkY5MzJBOEM6Njk3NjlBMkYiLCJ2aXNpdG9yX2lkIjoiMTI5NzcxODkxNTY0NzMxNDQ3OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 2c4ad36b6218fb6266d1b0d3db7d37a2c47d01ce0e7129f3baf7a114d839566f |
| hovercard-subject-tag | issue:2846829034 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/reactive-python/reactpy/1276/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9f82ed8e33f61383ad0b5f9d1ad381c4191e403a12948a7daac1dd9b0f304894/reactive-python/reactpy/issues/1276 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9f82ed8e33f61383ad0b5f9d1ad381c4191e403a12948a7daac1dd9b0f304894/reactive-python/reactpy/issues/1276 |
| og:image:alt | 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 fr... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Archmonger |
| hostname | github.com |
| expected-hostname | github.com |
| None | 032152924a283b83384255d9489e7b93b54ba01da8d380b05ecd3953b3212411 |
| turbo-cache-control | no-preview |
| go-import | github.com/reactive-python/reactpy git https://github.com/reactive-python/reactpy.git |
| octolytics-dimension-user_id | 106191177 |
| octolytics-dimension-user_login | reactive-python |
| octolytics-dimension-repository_id | 171410703 |
| octolytics-dimension-repository_nwo | reactive-python/reactpy |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 171410703 |
| octolytics-dimension-repository_network_root_nwo | reactive-python/reactpy |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 5b577f6be6482e336e3c30e8daefa30144947b17 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width