Repository navigation
[Backport core/1.55] Settle outstanding agent operations during detach - #19602
Conversation
## Summary Clean replacement for #18276. It preserves the reviewed three-file detach fix without the old branch history that violated the commit-trailer policy. - settle in-flight, queued, and open CRDT batches when the sender detaches - isolate settlement-listener failures so later batches still settle and unsubscribe still runs - keep detach idempotent - preserve the late-result accounting merged in #18538 ## Validation - `opSender.test.ts` and `opCoalescer.test.ts`: 61 tests passed - app typecheck passed - changed-file ESLint, Oxlint, and formatting checks passed - pre-commit quality gates passed ## End-to-end coverage No new browser test is included because this fix is at the sender teardown boundary: the regression is the exact settlement outcome and callback order for in-memory queued batches, including a failed initial transport send. Those states are not observable through the browser UI. The focused unit tests exercise the timer, transport, settlement, and repeated-detach boundaries directly, and the changed production lines have 100% diff coverage.
|
Important Review skippedIgnore keyword(s) in the title. ⛔ Ignored keywords (2)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository: Comfy-Org/ComfyUI_frontend/.coderabbit.yaml Review profile: ASSERTIVE Plan: Team Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
🎭 Playwright: ✅ 2121 passed, 0 failed · 2 flaky📊 Browser Reports
🎨 Storybook: ✅ Built — View Storybook🌾 Fallow: ✅ PassedFallow audits the diff for duplication, complexity and dead code. It gates on new findings only, so when the audit completes, a red is something this PR introduced or moved — never inherited backlog. A red can also mean the audit itself did not finish; the details below say which happened. No new findings in the changed files. Reproduce locally# the base the gate compared against
npx fallow audit --root . --quiet --format json \
--changed-since 51bf8b857d68836e582cfd607fad13a021f7f0a3
Full docs: ADR-DEVEX-LINT-0015 🧩 Custom Nodes Ecosystem Matrix: ✅ PassedExecutes the frontend JS of every registry pack that ships any, against this change, in both renderers. The eight
On a pin-bump PR, a red gate means the ecosystem moved — not that your diff broke something. That is what the bump PR is for. Outside a pin bump or a cold rebuild of the unpinned tail, a red means the diff. Note the corpus size and the executed count are different numbers, and the verdict is against the executed count: roughly 3,100 of ~5,100 packs ship no extension-shaped JS and are skipped. Reproduce locally# build one shard's fixture, then run it
python3 scripts/registry-census/build_matrix.py --shard 1/4
MATRIX_RENDERER=vue MATRIX_VUE=1 \
npx vitest run --config vitest.matrix.config.mts
Full docs: scripts/registry-census/README.md |
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## core/1.55 #19602 +/- ##
=============================================
- Coverage 84.65% 84.65% -0.01%
=============================================
Files 2314 2314
Lines 131514 131531 +17
Branches 33212 35095 +1883
=============================================
+ Hits 111328 111341 +13
- Misses 19828 19832 +4
Partials 358 358
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🔍 Cursor Review — Consolidated panel
Triggered by @christian-byrne.
Found 6 finding(s).
| Severity | Count |
|---|---|
| 🟡 Medium | 3 |
| 🟢 Low | 3 |
Panel: 8/8 reviewers contributed findings.
| queue.length = 0 | ||
| open = null | ||
| unsubscribe() | ||
| try { |
There was a problem hiding this comment.
🟡 Medium — detach() now sets detached = true and delegates all clearing to drainOutstanding(), whose first statement seal() runs chunkWireOps -> JSON.stringify over every open op and can throw on a non-serializable value (BigInt, circular widget value); a throw there — or from unsubscribe() — leaves inFlight with its armed timer, queue, and open populated, which the old straight-line clears could never do. The new if (detached) return makes every retry a no-op, so that half-torn-down state is permanent and contradicts the "permanently stop this sender" contract. Splice the queue and null inFlight/open (clearing the timer) before the chunking work, or clear in the finally; abortAll() has the same exposure with no finally at all. Raised by 4 of 8 reviewers (claude-opus-5-thinking-max adversarial, claude-opus-5-thinking-max edge-case, gpt-5.6-sol-max adversarial, gpt-5.6-sol-max edge-case).
| } | ||
| } | ||
|
|
||
| function settle(outcome: BatchOutcome): void { |
There was a problem hiding this comment.
🟡 Medium — This PR adds guardedSettlementNotifier on the premise that deps.onBatchSettled can throw, but settle() — the path every acknowledged, unacknowledged, and unbound batch takes — still calls it bare, after inFlight = null and before pump(). A throwing listener therefore leaves inFlight === null with a non-empty queue and no armed timer, stalling the FIFO until some unrelated later enqueue()/flush() happens to re-drive it, and it cuts the abortIfUnbound() settle->pump->transmit cascade short. Raised by 2 of 8 reviewers (claude-opus-5-thinking-max adversarial, claude-opus-5-thinking-max edge-case).
| }) | ||
| return | ||
| } | ||
| if (workflowId === null) { |
There was a problem hiding this comment.
🟡 Medium — The new detached branch just above routes its settlement through guardedSettlementNotifier, but this sibling workflowId === null branch still calls deps.onBatchSettled unguarded. admit is invoked synchronously from graph-mutation code via coalescer.enqueue, so a throwing listener escapes into the middle of a litegraph edit instead of being contained, after projection.noteLocalWrites() has already recorded the write. Both branches settle the same { state: 'undeliverable', ops: minted } outcome and should share the guard. Raised by 3 of 8 reviewers (claude-opus-5-thinking-max adversarial, claude-opus-5-thinking-max edge-case, gemini-3.1-pro adversarial).
| mintWireOps([operation], { actor, baseVersion: baseVersion + index }) | ||
| ) | ||
| lastMintedVersion = baseVersion + minted.length - 1 | ||
| if (detached) { |
There was a problem hiding this comment.
🟢 Low — A fresh guardedSettlementNotifier is constructed on every detached admission, so its reportedFailure latch is always false and the once-only dedupe never takes effect here. A systematically throwing onBatchSettled emits one reportError per post-detach admit — from a hot edit path — which is exactly the telemetry flood the latch was added to prevent in detach()/abortAll(). Hoisting one detach-scoped notifier into the closure would bound it. Raised by 6 of 8 reviewers (claude-opus-5-thinking-max adversarial, gemini-3.1-pro adversarial, kimi-k3-max adversarial, claude-opus-5-thinking-max edge-case, gemini-3.1-pro edge-case, kimi-k3-max edge-case).
| lastMintedVersion = baseVersion + minted.length - 1 | ||
| if (detached) { | ||
| guardedSettlementNotifier('failure_settling_agent_op_sender_detach')({ | ||
| state: 'undeliverable', |
There was a problem hiding this comment.
🟢 Low — This path settles all minted ops as one outcome without passing them through chunkWireOps, so admit(300 ops) after detach emits a single 300-op undeliverable batch, while the new test at opSender.test.ts pins [256, 44] for the same 300 ops admitted just before detach. onBatchSettled consumers therefore see batch sizes that depend only on which side of detach() an admission landed. Raised by 2 of 8 reviewers (gemini-3.1-pro adversarial, claude-opus-5-thinking-max edge-case).
|
|
||
| function admit(operations: GraphOperation[]): void { | ||
| if (detached || operations.length === 0) return | ||
| if (operations.length === 0) return |
There was a problem hiding this comment.
🟢 Low — Dropping detached from this guard means a permanently stopped sender still calls deps.workflowId(), deps.baseVersion(), and deps.actor(), mints a fresh uuid per op, and advances lastMintedVersion after the owner explicitly detached. In useAgentCrdtFollower's teardown, sender.detach() runs several steps before projection.destroy(), so a late admission settles against an about-to-be-destroyed projection. Settling without minting (or guarding the dep reads) would keep the intended undeliverable behavior without the extra exposure. Raised by 3 of 8 reviewers (gemini-3.1-pro adversarial, claude-opus-5-thinking-max adversarial, kimi-k3-max adversarial).
Summary
Manual
core/1.55backport of #19595. It settles in-flight, queued, open, and post-detach agent operations without silent drops, isolates settlement-listener failures, and preserves late-result accounting.Validation
fallow, lint, typecheck, agent review, and 100% diff coverage