fix: revive deephaven.ui widgets after a reconnect#1390
Open
fyrkov wants to merge 3 commits into
Open
Conversation
When the frontend<->backend connection drops and recovers, the patched JsWidget (deephaven-core) reopens its message stream on the same widget object and fires a `reconnect` event. WidgetHandler previously keyed every per-stream reset on the widget *object reference* changing, so nothing reset on a same-object revive: the new stream's from-empty document patch was applied on top of the stale document and stale callable closures were reused, so the button invoked a dead-stream callable the new server stream never registered (`Callable not found: cbN`). Listen for the widget `reconnect` event and, on it, close stale exported objects, clear the exported-object and callable maps, reset the document, and re-send `setState` so the server re-renders from scratch. Track the latest state received from the server (not just the panel-open snapshot) so the widget is restored to its current state after reconnect. Requires the companion JsWidget/WorkerConnection reconnect support in deephaven-core, which provides the `reconnect` event this keys off. Ref: deephaven/deephaven-core#3604
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the deephaven.ui widget client to correctly recover after a same-session disconnect/reconnect by resetting per-stream client state and re-sending the last known widget state so the server re-renders from scratch.
Changes:
- Track and persist the last widget state received from the server, and re-send it on widget
reconnect. - On reconnect, clear stale exported objects/callables and reset the rendered document/loading state.
- Expand test utilities and add/adjust unit tests to cover reconnect behavior and optional state transport.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| plugins/ui/src/js/src/widget/WidgetTestUtils.ts | Extend documentPatched test helpers to optionally include the serialized state param. |
| plugins/ui/src/js/src/widget/WidgetHandler.tsx | Add reconnect handling, last-received-state tracking, and cleanup/reset logic to revive widgets after reconnect. |
| plugins/ui/src/js/src/widget/WidgetHandler.test.tsx | Add reconnect unit test and update existing tests for the additional event listener and cleanup behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Address Copilot review feedback on deephaven#1390: type the METHOD_DOCUMENT_PATCHED state param as optional and validate the parsed state is a plain object before using it, so unexpected server values don't flow into setState/onDataChange.
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.
The deephaven-plugins half of a two-repo fix. Depends on a companion deephaven-core change (not yet submitted) that makes
JsWidgetfire areconnectevent after reopening its stream; also relies on the transport-reconnect fix deephaven/deephaven-core#8238. Should not merge before the core PR lands (linked here once opened).On that
reconnectevent,WidgetHandlernow closes stale exported objects, clears the exported-object and callable maps, resets the document, and re-sends the lastsetStateso the server re-renders from scratch instead of patching onto a stale document with dead callables.Fixes #1389