Repository navigation
fix(frontend): stop opening a y-websocket connection on every compile - #9200
aglinxinyuan wants to merge 1 commit into
Conversation
Each debounced compile planned a filtered copy of the graph, built by ValidationWorkflowService.getValidTexeraGraph() as a new WorkflowGraph. Its SharedModel opened a WebsocketProvider to a fresh rtc/<uuid> room that nothing ever closed, so every edit left one more socket retrying forever. The compile now plans the live graph and keeps only the valid operators and the links between them; getValidTexeraGraph() becomes getValidOperatorIDs(). The compile subscription also stops when the service is destroyed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Backport auto-label reportThis
|
Automated Reviewer SuggestionsBased on the
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9200 +/- ##
============================================
- Coverage 91.98% 91.98% -0.01%
Complexity 5084 5084
============================================
Files 1281 1281
Lines 55806 55799 -7
Branches 7076 7076
============================================
- Hits 51333 51326 -7
Misses 2732 2732
Partials 1741 1741
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
What changes were proposed in this PR?
Every debounced workflow edit (500 ms) opened a new y-websocket connection that was never closed.
WorkflowCompilingServicecompiled a filtered copy of the graph:ValidationWorkflowService.getValidTexeraGraph()returnednew WorkflowGraph(validOperators, validLinks, ...). TheWorkflowGraphconstructor always builds aSharedModel, and that always opens aWebsocketProviderto a freshrtc/<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 itsY.Doc, two 3 s intervals and its listeners.This PR stops building the copy:
WorkflowCompilingServicenow plans the live graph withExecuteWorkflowService.getLogicalPlanRequest, then keeps only the valid operators and the links between them.ValidationWorkflowService.getValidTexeraGraph()becomesgetValidOperatorIDs(), which only returns the set of operator IDs that pass validation.@UntilDestroy()anduntilDestroyed(this), as inValidationWorkflowService).The plan sent to
/compileis unchanged. With no target operator,getSubDAGreturns 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()callingdisconnect()instead ofdestroy()) 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:WebSocketand runs two debounced compiles. Onmainit fails, recording twows://localhost:3000/rtc/<uuid>sockets, one per compile. With this PR it records none.main(the service has nongOnDestroy) and passes here.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.main's production code: 2 failed (the two above), 48 passed.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)