Prevent re-opening websocket connections on metadata update#3093
Merged
Conversation
aglinxinyuan
approved these changes
Nov 20, 2024
PurelyBlank
pushed a commit
that referenced
this pull request
Dec 4, 2024
This PR fixes #3085. The issue is caused by a call of `this.workflowActionService.setWorkflowMetadata(updatedWorkflow);` in `persistWorkflow`. This call caused the WebSocket service to detect a workflow metadata update and reopen the WebSocket unnecessarily. Therefore, the bug can be consistently reproduced by hitting the save button on the workflow canvas. This PR introduces a logic check to skip reopening the WebSocket if the wid remains unchanged, preventing redundant reconnections.
SarahAsad23
pushed a commit
to madisonmlin/texera
that referenced
this pull request
May 20, 2026
) This PR fixes apache#3085. The issue is caused by a call of `this.workflowActionService.setWorkflowMetadata(updatedWorkflow);` in `persistWorkflow`. This call caused the WebSocket service to detect a workflow metadata update and reopen the WebSocket unnecessarily. Therefore, the bug can be consistently reproduced by hitting the save button on the workflow canvas. This PR introduces a logic check to skip reopening the WebSocket if the wid remains unchanged, preventing redundant reconnections.
kunwp1
added a commit
to kunwp1/texera
that referenced
this pull request
Jun 8, 2026
…rd (apache#3120) WorkflowWebsocketService, ComputingUnitStatusService, and the execution-session services (WorkflowStatusService, ExecuteWorkflowService, WorkflowConsoleService, WorkflowResultService) are all root-scoped singletons, so their state outlived the workspace. WorkspaceComponent.ngOnDestroy cleared the workflow graph but never tore down the websocket session, leaving the socket open and the derived state (connection tracking, worker count, execution status, console output, result caches) populated. Re-entering a workflow then reused the stale session; for the same wid (the wid -> null -> wid pattern) the reconnect guard even short-circuited, the case PR apache#3093's in-canvas guard did not cover. Tear down every piece of websocket-derived state on workspace destroy: ComputingUnitStatusService.disconnect() (close socket, clear status, stop polling, reset connection tracking and selected unit), WorkflowWebsocketService.closeWebsocket() (reset numWorkers), ExecuteWorkflowService.resetState() (execution state + worker assignments), WorkflowConsoleService.clearConsoleMessages(), and WorkflowResultService.clearResults() (result caches + table-stats ReplaySubject). WorkspaceComponent.ngOnDestroy invokes all of them so re-entering any workflow (same wid included) starts from a clean session.
zyratlo
pushed a commit
to zyratlo/texera
that referenced
this pull request
Jun 9, 2026
…rd (apache#5565) ### What changes were proposed in this PR? Websocket-derived front-end state (the connection itself, plus the execution status, console output, and results built from its events) lives in singletons outside the workspace. It was never torn down in two cases, so stale state carried over: 1. **Returning to the dashboard** and re-entering a workflow reused the previous socket. The connection-tracking fields (`currentConnectedWid` / `currentConnectedCuid`) also survived, so the reconnect guard saw them unchanged, skipped reconnecting, and reused the stale socket. (apache#3120 — the case apache#3093 did not cover.) 2. **Switching computing units** inside the workspace left the previous unit's console, results, and execution status on screen. This PR clears that state at both points. **Workspace exit**: `WorkspaceComponent.ngOnDestroy()` now tears everything down: | Call *(new)* | Resets | | --- | --- | | `ComputingUnitStatusService.disconnect()` | closes the socket, clears operator status, stops the unit poll, resets the connection-tracking fields and the selected unit | | `ExecuteWorkflowService.resetExecutionAndWorkers()` | execution status and worker assignments | | `WorkflowConsoleService.clearConsoleMessages()` | console output | | `WorkflowResultService.clearResults()` | result caches and table stats | **Unit switch**: `ComputingUnitStatusService` emits a reset signal when it reconnects to a different unit, and `WorkspaceComponent` clears the same execution / console / result state in response. As a result, switching units now discards the previous unit's results and console instead of leaving them on screen. The remaining websocket-event consumers need no teardown: `OperatorReuseCacheStatusService` is stateless, and `udf-debug.service`'s state lives in the `TexeraGraph`, already reset by `clearWorkflow()`. ### Any related issues, documentation, discussions? Closes apache#3120. Related: apache#3093 (earlier partial fix for the in-canvas socket re-open). ### How was this PR tested? Test with this workflow [Untitled workflow (14).json](https://github.com/user-attachments/files/28696700/Untitled.workflow.14.json) https://github.com/user-attachments/assets/060fe1ac-39cf-45e5-b423-5aa27fe17aed ### Was this PR authored or co-authored using generative AI tooling? Generated-by: Claude Code (Claude Opus 4.8) --------- Co-authored-by: Xinyuan Lin <xinyual3@uci.edu>
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.
This PR fixes #3085. The issue is caused by a call of
this.workflowActionService.setWorkflowMetadata(updatedWorkflow);inpersistWorkflow. This call caused the WebSocket service to detect a workflow metadata update and reopen the WebSocket unnecessarily. Therefore, the bug can be consistently reproduced by hitting the save button on the workflow canvas.This PR introduces a logic check to skip reopening the WebSocket if the wid remains unchanged, preventing redundant reconnections.