aglinxinyuan opened a new pull request, #9200:
URL: https://github.com/apache/texera/pull/9200

   ### What changes were proposed in this PR?
   
   Every debounced workflow edit (500 ms) opened a new y-websocket connection 
that was never closed.
   
   `WorkflowCompilingService` compiled a filtered copy of the graph: 
`ValidationWorkflowService.getValidTexeraGraph()` returned `new 
WorkflowGraph(validOperators, validLinks, ...)`. The `WorkflowGraph` 
constructor always builds a `SharedModel`, and that always opens a 
`WebsocketProvider` to a fresh `rtc/<uuid>` room. The copy was only read to 
build the logical plan, and nothing destroyed it. So each edit left one more 
socket behind, retrying forever while the server was unreachable, along with 
its `Y.Doc`, two 3 s intervals and its listeners.
   
   This PR stops building the copy:
   - `WorkflowCompilingService` now plans the live graph with 
`ExecuteWorkflowService.getLogicalPlanRequest`, then keeps only the valid 
operators and the links between them.
   - `ValidationWorkflowService.getValidTexeraGraph()` becomes 
`getValidOperatorIDs()`, which only returns the set of operator IDs that pass 
validation.
   - The compile subscription now stops when the service is destroyed 
(`@UntilDestroy()` and `untilDestroyed(this)`, as in 
`ValidationWorkflowService`).
   
   The plan sent to `/compile` is unchanged. With no target operator, 
`getSubDAG` returns every enabled operator and link of a DAG, so filtering the 
plan afterwards keeps the same operators and links as filtering the graph 
first. The only difference is a cycle with no terminal operator, which 
execution already leaves out of its plan too.
   
   ### Any related issues, documentation, discussions?
   
   Fixes the per-edit leak ("Leak B") of #6239. The other half of that issue 
("Leak A", `SharedModel.destroy()` calling `disconnect()` instead of 
`destroy()`) is fixed in #9198, which also lists this leak as tracked 
separately. #6240 was an earlier attempt at both and was closed without merging.
   
   ### How was this PR tested?
   
   Added three tests to `workflow-compiling.service.spec.ts`:
   - **"opens no websocket when it compiles"** stubs the global `WebSocket` and 
runs two debounced compiles. On `main` it fails, recording two 
`ws://localhost:3000/rtc/<uuid>` sockets, one per compile. With this PR it 
records none.
   - **"stops compiling once the service is destroyed"** fails on `main` (the 
service has no `ngOnDestroy`) and passes here.
   - **"leaves an invalid operator, and the links touching it, out of the 
logical plan"** passes on both, showing the compiled plan is unchanged.
   
   The validation and menu specs are updated for the renamed method.
   
   Commands, run on Node 24 (required since #9125):
   - `ng test --watch=false 
--include=src/app/workspace/service/compile-workflow/workflow-compiling.service.spec.ts
 
--include=src/app/workspace/service/validation/validation-workflow.service.spec.ts
 --include=src/app/workspace/component/menu/menu.component.spec.ts`: 3 files, 
232 tests passed.
   - The new compile spec against `main`'s production code: 2 failed (the two 
above), 48 passed.
   - Full frontend suite, `ng test --watch=false`: 244 files, 6921 passed, 1 
skipped.
   - `yarn format:ci`: clean.
   
   ### Was this PR authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Code (Opus 5.5)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to