Skip to content

fix: release aborted auth filesystem waiters - #21135

Merged
OrcaWin merged 1 commit into
mainfrom
np-oom-scan-auth-wait-retention
Sep 18, 2026
Merged

OrcaWin merged 1 commit into
mainfrom
np-oom-scan-auth-wait-retention

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Sep 17, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​203 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​203
Prod 12 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1756 $\color{#cf222e}{\Huge{\mathbf{−}}}$​21 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1735

Problem and change

Repeated quota polls wait on the same unfinished filesystem request. Each abandoned Promise.race leaves a reaction attached to that request; on the installed Electron runtime, the expired poll's rejection reason remains reachable until the filesystem request settles.

Reuse PromiseSettlementWaiters so one raw-result reaction serves detachable waiters. Preserve last-waiter cancellation, live siblings, late results and arbitrary abort reasons. Auth alone opts into microtask abort settlement to preserve the prior race ordering; existing registry consumers keep their current behavior. No timeout or admission policy changes.

Validation

  • Actual-source proof on Electron 43.7/Node 24: 128 expired ordinary Error objects retained before, one after. The remaining reason belongs to the operation's existing cancellation controller and releases with its owner. Node 26 already collects all but that one reason.
  • All 24 success/failure/abort ordering comparisons match. The separate 8 MiB amplified fixture uses synthetic payloads; ordinary Error byte size was not measured.
  • 50 auth/registry tests and 39 existing registry-consumer tests pass; the reconstructed baseline fails two regression cases. Node/Web/CLI typechecks, focused lint and changed-code quality pass. Root independently reran the 50 tests and Node/Electron proofs.

The portable proof includes source hashes and runtime-specific results. The native filesystem stall is injected; this does not identify a cause for #19831 or #19768 or reproduce their memory growth rate.

@coderabbitai

coderabbitai Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

📝 Walkthrough

Walkthrough

The change routes createAuthFilesystemOperation waits through PromiseSettlementWaiters. It adds microtask-deferred abort handling and supports arbitrary abort reasons. New tests cover settlement ordering, listener cleanup, shared waits, and garbage collection. Audit scripts and runtime results compare before and after behavior across Node and Electron.

Priority: ⬇️ Low

Merge Risk: 🔵 Low · up to 90162

Calls aborted with a null reason receive a generated error instead of their supplied reason, and shared cancellation can observe a different error instance. Add null-preservation before merging.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the problem, implementation, scope, and validation, but it does not follow the required template. It omits the required ELI5, What Changed, Why, Linked Issue with a Fixes refe… Add the missing template sections. Include a linked issue using the required "Fixes #..." format, mark Visual Proof as N/A with a reason if applicable, document manual and automated testing, complete the required checklists, and address com…
Docstring Coverage ⚠️ Warning Docstring coverage is 9.09% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 8 files. (6 skipped: 6… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: releasing aborted auth filesystem waiters.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description explains the problem, implementation, scope, and validation, but it does not follow the required template. It omits the required ELI5, What Changed, Why, Linked Issue with a Fixes reference, Visual Proof, Testing checklist, AI Disclosure, Review, boundary, Notes, and Checklist sections.

Resolution

Add the missing template sections. Include a linked issue using the required "Fixes #..." format, mark Visual Proof as N/A with a reason if applicable, document manual and automated testing, complete the required checklists, and address compatibility, security, performance, and remote-platform considerations.

Full details: Docstring Coverage

Explanation

Docstring coverage is 9.09% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 8 files. (6 skipped: 6 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai 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.

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

🟡 Minor · Preserve null abort reasons. · auth-filesystem-operation.ts:19-20

src/main/rate-limits/auth-filesystem-operation.ts:19-20
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Preserve null abort reasons.

AbortController.abort(null) preserves signal.reason as null, but getAbortReason() replaces it with a new Error. The waiter and shared operation call the helper separately, so they can receive different errors.

Return signal.reason directly. Add null to both abort-reason matrices.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: d33213b2-ad6a-473a-b2f4-47a439b8739e

📥 Commits

Reviewing files that changed from the base of the PR and between 77cd61d and 90162ad.

📒 Files selected for processing (14)
  • docs/audits/auth-filesystem-wait-retention/README.md
  • docs/audits/auth-filesystem-wait-retention/before.config.mjs
  • docs/audits/auth-filesystem-wait-retention/electron-results.json
  • docs/audits/auth-filesystem-wait-retention/fix.patch
  • docs/audits/auth-filesystem-wait-retention/node-results.json
  • docs/audits/auth-filesystem-wait-retention/reproduce.cjs
  • docs/audits/auth-filesystem-wait-retention/settlement-order.cjs
  • docs/audits/auth-filesystem-wait-retention/source-versions.json
  • docs/audits/auth-filesystem-wait-retention/sources.cjs
  • docs/audits/auth-filesystem-wait-retention/validation.json
  • src/main/rate-limits/auth-filesystem-operation-retention.test.ts
  • src/main/rate-limits/auth-filesystem-operation.ts
  • src/shared/promise-settlement-waiters.test.ts
  • src/shared/promise-settlement-waiters.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

  • Detach aborted auth waits — createAuthFilesystemOperation now routes each caller through PromiseSettlementWaiters(result, onSettled) instead of Promise.race([result, aborted]), so the shared raw promise keeps exactly one reaction and expired poll reasons are collectible; last-waiter cancellation and the ownership waiters set still fire from the returned promise's .finally.
  • Opt-in deferred abort settlement — PromiseSettlementWaitOptions.abortInMicrotask (default false, so every existing registry consumer is unchanged) queues abandonment in a queueMicrotask, reproducing the old Promise.race ordering when abort and raw settlement share a turn. createAbortError/abandon widen to unknown so arbitrary auth abort reasons survive.
  • Regression coverage — new auth-filesystem-operation-retention.test.ts proves each abandoned poll's reason is GC-collectible while one native operation stays pending and that no extra result.then reaction is added; ordering cases added to the PromiseSettlementWaiters suite. Tests rely on --expose-gc, which config/vitest.config.ts pins.
  • Portable proof — docs/audits/auth-filesystem-wait-retention/** (reverse-patch fix.patch, Node/Electron result JSON, source-version hashes, reproduction scripts).

I verified the settlement ordering myself: with abortInMicrotask the abort abandonment loses to an already-queued raw settlement and wins over a later one, matching the prior race; settled is set synchronously in onSettled before any .finally runs, so last-waiter cancellation still sees a settled operation. The regression tests can genuinely fail on the baseline (Promise.race re-subscribes result.then, and the old registry ignores abortInMicrotask). Focused runs pass with config/vitest.config.ts (15/15 retention; full PromiseSettlementWaiters suite green).

ℹ️ null abort reason is a pre-existing edge case

getAbortReason (auth-filesystem-operation.ts:19) is untouched by this PR, and its signal.reason ?? new Error(...) fallback already turned an explicit abort(null) into a fresh Error on the baseline — the waiter and the shared operation each call it, so they could differ. This PR's widened type and arbitrary-reason matrix (false, 0, strings, objects) do not change that behavior, so it is not a regression here. Normalizing signal.reason (including null) and adding null to the matrices would make the "arbitrary abort reasons" claim fully true, but it is optional and out of this change's scope.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@OrcaWin
OrcaWin merged commit f90370f into main Sep 18, 2026
29 checks passed
ivanvykopal pushed a commit to ivanvykopal/orca that referenced this pull request Sep 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant