Repository navigation
[Backport cloud/1.55] Settle outstanding agent operations during detach - #19603
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 |
🎨 Storybook: ✅ Built — View Storybook🎭 Playwright: ✅ 2121 passed, 0 failed · 1 flaky📊 Browser Reports
🌾 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 e268690bf686b08ac522cc2abf6a2adb8a8f1df3
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 @@
## cloud/1.55 #19603 +/- ##
=============================================
Coverage ? 80.55%
=============================================
Files ? 2210
Lines ? 117142
Branches ? 35458
=============================================
Hits ? 94364
Misses ? 22391
Partials ? 387
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🔍 Cursor Review — Consolidated panel
Triggered by @christian-byrne.
Found 5 finding(s).
| Severity | Count |
|---|---|
| 🟡 Medium | 2 |
| 🟢 Low | 3 |
Panel: 8/8 reviewers contributed findings.
| } | ||
| } | ||
|
|
||
| function settle(outcome: BatchOutcome): void { |
There was a problem hiding this comment.
🟡 Medium — settle() still calls deps.onBatchSettled(outcome) raw, so the throwing listener this change hardens against still escapes on the acknowledged/timeout path — and the consequence is worse there: settle() nulls inFlight before notifying but calls pump() after, so a throw leaves queued batches with nothing in flight and no timer armed until an unrelated enqueue()/flush() happens to pump them, while the exception escapes into the doc_ops_result dispatch and the result-timeout callback. Route this call through guardedSettlementNotifier as well.
Raised by 3 of 8 reviewers (claude-opus-5-thinking-max adversarial, claude-opus-5-thinking-max edge-case, kimi-k3-max adversarial).
| } | ||
|
|
||
| function drainOutstanding(notify: (outcome: BatchOutcome) => void): void { | ||
| seal() |
There was a problem hiding this comment.
🟡 Medium — drainOutstanding() begins with seal() — which chunks the open batch and JSON-serializes each op for wire sizing — before clearing the in-flight timer or splicing the queue, so a non-serializable widget value (circular ref, BigInt, throwing toJSON) aborts teardown half-done: in detach() detached is already latched, the result-timeout timer stays armed, pending() stays non-zero and nothing is settled; in abortAll() old-lineage in-flight/queued work survives the reset. The previous detach() cleared the timer and queue unconditionally — do that before, or independently of, the fallible sealing work.
Raised by 2 of 8 reviewers (gpt-5.6-sol-max adversarial, claude-opus-5-thinking-max adversarial).
| ) | ||
| lastMintedVersion = baseVersion + minted.length - 1 | ||
| if (detached) { | ||
| guardedSettlementNotifier('failure_settling_agent_op_sender_detach')({ |
There was a problem hiding this comment.
🟢 Low — The detached branch constructs a new guardedSettlementNotifier on every admit() call, so reportedFailure resets each time and the report-once behavior the new detach tests pin does not hold here. Since admit no longer bails when detached, a listener that throws consistently (e.g. settleHumanOps reaching a projection already destroyed in teardown) emits one reportError per admitted batch, and a single node drag admits many — hoist one notifier per sender, or reuse the detach-time one, to bound it.
Raised by 5 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, kimi-k3-max edge-case).
| return | ||
| } | ||
| if (workflowId === null) { | ||
| deps.onBatchSettled({ state: 'undeliverable', ops: minted }) |
There was a problem hiding this comment.
🟢 Low — The workflowId === null branch sits two lines below the newly guarded detached branch but still calls deps.onBatchSettled raw, so a throwing listener propagates out of admit()/enqueue() into the graph-mutation caller after lastMintedVersion was already advanced on line 333 — the ops are lost and the version counter has moved. Use the same notifier here so all three settle-on-admit paths behave alike.
Raised by 4 of 8 reviewers (claude-opus-5-thinking-max adversarial, kimi-k3-max adversarial, claude-opus-5-thinking-max edge-case, kimi-k3-max edge-case).
|
|
||
| function drainOutstanding(notify: (outcome: BatchOutcome) => void): void { | ||
| seal() | ||
| const queued = queue.splice(0) |
There was a problem hiding this comment.
🟢 Low — drainOutstanding splices the queue and nulls inFlight before notifying, and the guard swallows every failure after the first report, so a batch whose settleHumanOps throws is dropped from the sender while projection.settleLocalWrites never runs for it — those optimistic local writes stay pending forever, with at most one reportError per drain no matter how many batches failed. Consider surfacing the failure count (or settling the projection defensively) so the divergence isn't invisible.
Raised by 1 of 8 reviewers (claude-opus-5-thinking-max adversarial).
Summary
Manual
cloud/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