Skip to content

fix: show users an error notification when a widget fails after render (#320) - #474

Merged
cpsievert merged 8 commits into
mainfrom
fix/widget-error-notifications
Nov 13, 2026
Merged

cpsievert merged 8 commits into
mainfrom
fix/widget-error-notifications

Conversation

@cpsievert

@cpsievert cpsievert commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

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 without vl-convert-python installed) — 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 sets sanitize_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) and tests/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 check passes (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.

@cpsievert
cpsievert requested a balanced review from Copilot November 12, 2026 21:42
@cpsievert
cpsievert marked this pull request as ready for review November 12, 2026 21:42

This comment was marked as resolved.

This comment was marked as outdated.

)

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the changes that surface post-render widget failures through user notifications.

No open issues 🎉

Review effort: Balanced

…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>

This comment was marked as resolved.

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>
@cpsievert
cpsievert merged commit 2601d96 into main Nov 13, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Widget errors after render (comm open, browser-message callbacks) should reach the user, not just the server log

2 participants