Repository navigation
fix: show users an error notification when a widget fails after render (#320) - #474
Merged
Merged
Conversation
) The dispatch, not the logging filter, now shows the notification: the filter only notes the exception's message on the dispatch scope. Reusing one notification id per widget lets the browser replace a repeat, so the per-comm set of shown messages, its cap, and the comm reference on the scope are gone. A traitlets warning without an exception no longer notifies.
…gelog (#320) Render invalidation or session end already cleans up the half-initialized widget, so closing it early wasn't worth the nested error handling. Co-Authored-By: Claude <noreply@anthropic.com>
Its placeholder comm would otherwise keep queuing widget.send() messages that can never be delivered, until the output re-renders or the session ends. Process-global widgets are left alone: another session's open still drains their queue. Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #320.
A widget that fails after its render function returned — while its comm opens (a display hook or
get_state()raising) or in a callback triggered by a browser message (e.g. an Altair/VegaFusion chart withoutvl-convert-pythoninstalled) — previously left the output silently blank forever. Now the user gets a sticky error notification and the app keeps working; the full error message is shown locally and the generic sanitized message where the app setssanitize_errors(e.g. Posit Connect). Errors are still logged server-side, and a widget whose callback keeps failing shows a single notification, updated with its latest error, rather than a flood of them.The issue's longer-term idea — an in-place error state in the JS output binding — is intentionally not in this PR.
Verification
New unit tests cover both paths:
tests/unit/test_widget_display.py(comm-open failure notifies the user; sanitized variant) andtests/unit/test_callback_errors.py(callback failure notifies; repeat failures reuse one notification per widget; a warning without an exception doesn't notify; sanitized variant).make checkpasses (format, pyright, 1145 unit tests). Also checked in headless Chromium with two widgets whose click handlers raise: repeated failures leave one notification per widget, and the session stays alive.