Skip to content

fix(agent): report late billing refresh failures [cloud/1.56] - #20951

Merged
christian-byrne merged 1 commit into
cloud/1.56from
christian-byrne/backport-credit-refresh-late-error-cloud-1.56
Oct 13, 2026
Merged

christian-byrne merged 1 commit into
cloud/1.56from
christian-byrne/backport-credit-refresh-late-error-cloud-1.56

Conversation

@christian-byrne

Copy link
Copy Markdown
Contributor

Summary

  • report billing refresh rejection even when it arrives after the freshness timeout
  • expose shared refresh readiness for deterministic reopen tests
  • replace timing sleeps with observable readiness checks

Validation

  • pnpm vitest run src/workbench/extensions/agent/composables/useAgentDockMount.test.ts src/workbench/extensions/agent/stores/agent/agentPanelStore.test.ts (53 passed)
  • pnpm typecheck

Follow-up carrier for #20929 after review.

@christian-byrne
christian-byrne requested review from a team as code owners October 13, 2026 21:36
@christian-byrne
christian-byrne requested a review from a team as a code owner October 13, 2026 21:36
@christian-byrne christian-byrne added the cursor-review Trigger multi-model Cursor agent review on this PR label Oct 13, 2026
@coderabbitai

coderabbitai Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Repository: Comfy-Org/ComfyUI_frontend/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Team
  • Run ID: ad0a3d47-a383-4a8e-990e-88abb8555dfc

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

🎨 Storybook: ✅ Built — View Storybook

Details

⏰ Completed at: 10/13/2026, 09:38:45 PM UTC

Links

🌾 Fallow: ✅ Passed

Fallow 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 fc4871b82084fe6190fa5e3499209392aeb4e641

Full docs: ADR-DEVEX-LINT-0015

🎭 Playwright: ✅ 2201 passed, 0 failed · 1 flaky

📊 Browser Reports
  • chromium: View Report (✅ 2179 / ❌ 0 / ⚠️ 1 / ⏭️ 0)
  • chromium-2x: View Report (✅ 2 / ❌ 0 / ⚠️ 0 / ⏭️ 0)
  • chromium-0.5x: View Report (✅ 1 / ❌ 0 / ⚠️ 0 / ⏭️ 0)
  • mobile-chrome: View Report (✅ 19 / ❌ 0 / ⚠️ 0 / ⏭️ 0)

🧩 Custom Nodes Ecosystem Matrix: ✅ Passed

Executes the frontend JS of every registry pack that ships any, against this change, in both renderers. The eight ecosystem-matrix shard checks are a harness self-test; the pack verdict is matrix-verdict.

Stage Result What a failure here means
pin-status success Informational. It never fails the build; it warns when the corpus snapshot is over 30 days old.
corpus success Infrastructure: the pack mirror could not be fetched, validated or cached. Not your diff.
shards success Harness integrity, not pack breakage. A shard only checks that every built spec wrote its row; vitest's own exit code is deliberately ignored because pack code leaks unhandled rejections.
verdicts success The population verdict per renderer. This is the stage that judges packs. Exit 1 is FAIL; exit 2 is withheld — rows were missing, so nothing was measured, which is not the same as your change breaking packs.
detection-proofs success The instrument self-test: the matrix must FAIL on a deliberately poisoned corpus. A failure here means the gate cannot be trusted this run, in either direction.

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

@christian-byrne
christian-byrne merged commit b7d4675 into cloud/1.56 Oct 13, 2026
140 checks passed
@christian-byrne
christian-byrne deleted the christian-byrne/backport-credit-refresh-late-error-cloud-1.56 branch October 13, 2026 21:44
@github-actions github-actions Bot added the risk:high PR risk grade (advisory shadow check; grader-owned) label Oct 13, 2026
@codecov

codecov Bot commented Oct 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

@@              Coverage Diff              @@
##             cloud/1.56   #20951   +/-   ##
=============================================
  Coverage              ?   82.99%           
=============================================
  Files                 ?     2381           
  Lines                 ?   126601           
  Branches              ?    38617           
=============================================
  Hits                  ?   105078           
  Misses                ?    21114           
  Partials              ?      409           
Flag Coverage Δ
unit 82.99% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
.../extensions/agent/composables/useAgentDockMount.ts 93.65% <100.00%> (ø)
...h/extensions/agent/stores/agent/agentPanelStore.ts 98.59% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Cursor Review — Consolidated panel

Triggered by @christian-byrne.

Found 6 finding(s).

Severity Count
🟡 Medium 1
🟢 Low 4
⚪ Nit 1

Panel: 8/8 reviewers contributed findings.

billingRefreshes.delete(key)
}
if (latestBillingRefresh === refresh) latestBillingRefresh = undefined
billingRefreshCount.value -= 1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium — The decrement runs in pending.finally(...), so billingRefreshPending flips to false a microtask or two before the refresh promise callers actually hold settles — i.e. before refreshTransitionBaseline's .then has run completeCreditTransitionRefresh/observeFreshScopedFunds — yet the new tests at useAgentDockMount.test.ts:283 and :338 gate on it as a refresh-complete barrier. It also reports idle as soon as the 15s timeout resolves while fetchStatus is still outstanding; the onLateError path added here is proof that work continues past that point. Putting the real assertion inside vi.waitFor (or awaiting the refresh promise) avoids depending on a flag that cannot mean "consumers have run". Raised by 2 of 8 reviewers (claude-opus-5-thinking-max edge-case, claude-opus-5-thinking-max adversarial).

.then(fetchStatus)
.then(resolve, reject)
.then(resolve, (error: unknown) => {
if (timedOut) onLateError?.(error)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Low — onLateError is invoked inside a rejection handler whose chain (.then(...).finally(...)) is never returned or awaited, so a callback that throws becomes an unhandled promise rejection with no catch anywhere — the previous handler was bare reject, which could not throw. Today's only caller is reportError, but this is public store API open to any callback; wrapping the invocation in try/catch keeps the late-error reporting path itself failure-safe. Raised by 5 of 8 reviewers (claude-opus-5-thinking-max adversarial, gemini-3.1-pro adversarial, claude-opus-5-thinking-max edge-case, gemini-3.1-pro edge-case, kimi-k3-max edge-case).

onLateError?: (error: unknown) => void
): Promise<boolean> {
const existing = billingRefreshes.get(key)
if (existing) return existing

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Low — The dedupe early-return discards a joining caller's onLateError, so only the first caller for a key ever registers one. Combined with the parameter being optional, any call site that omits it — or joins one that did — still silently swallows post-timeout rejections, the exact failure this change set out to fix. Making the parameter required, or defaulting to a store-level reportError, keeps late failures visible regardless of call site. Raised by 2 of 8 reviewers (claude-opus-5-thinking-max adversarial, claude-opus-5-thinking-max edge-case).


expect(fetchStatusFresh).toHaveBeenCalledOnce()
await new Promise((resolve) => setTimeout(resolve, 0))
expect(store.billingRefreshPending).toBe(true)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Low — Unlike the other three substitutions, this one replaces the flush with an assertion that the refresh is still pending, so the following claimCreditTransitionNoticeImpression check now runs before the refresh settles rather than after — a different property than the test previously proved — and the fetch chain plus its 15s timeout are left dangling at test end. If the intent is "the notice is not claimable while the refresh is in flight", keep it but assert that explicitly; otherwise wait for completion like the sibling cases. Raised by 1 of 8 reviewers (gemini-3.1-pro edge-case).

@@ -423,8 +432,10 @@ export const useAgentPanelStore = defineStore('agentPanel', () => {
billingRefreshes.delete(key)
}
if (latestBillingRefresh === refresh) latestBillingRefresh = undefined

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Low — latestBillingRefresh is cleared only when the settling refresh is the newest one, so if a second refresh starts and finishes before an older one, the pointer is nulled while the older fetch is still in flight and the next afterCurrent: true reopen refresh runs immediately instead of queueing behind it. Pre-existing, but it sits in the bookkeeping this PR is tightening, and the new counter makes "nothing outstanding" cheap to detect. Raised by 1 of 8 reviewers (gemini-3.1-pro edge-case).

ready: boolean
} | null>(null)
const billingRefreshes = new Map<string, Promise<boolean>>()
const billingRefreshCount = ref(0)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ Nit — billingRefreshPending has no production consumer — the only readers are useAgentDockMount.test.ts — so this adds internal refresh bookkeeping to the public store surface purely as a test synchronisation hook, and couples those tests to the counter rather than to observable panel behaviour. Raised by 1 of 8 reviewers (claude-opus-5-thinking-max adversarial).

This branch was previously deployed

1 inactive deployment
website-approval — f81c102f Deployed Oct 13, 2026 by christian-byrne via fast-lane #1537
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cursor-review Trigger multi-model Cursor agent review on this PR risk:high PR risk grade (advisory shadow check; grader-owned)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant