Repository navigation
fix: release aborted auth filesystem waiters - #21135
Conversation
📝 WalkthroughWalkthroughThe change routes Priority: ⬇️ Low Merge Risk: 🔵 Low · up to 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)
✅ Passed checks (3 passed)
Full details: Description checkExplanation 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 CoverageExplanation 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.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
🟡 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 winPreserve
nullabort reasons.
AbortController.abort(null)preservessignal.reasonasnull, butgetAbortReason()replaces it with a newError. The waiter and shared operation call the helper separately, so they can receive different errors.Return
signal.reasondirectly. Addnullto both abort-reason matrices.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: d33213b2-ad6a-473a-b2f4-47a439b8739e
📒 Files selected for processing (14)
docs/audits/auth-filesystem-wait-retention/README.mddocs/audits/auth-filesystem-wait-retention/before.config.mjsdocs/audits/auth-filesystem-wait-retention/electron-results.jsondocs/audits/auth-filesystem-wait-retention/fix.patchdocs/audits/auth-filesystem-wait-retention/node-results.jsondocs/audits/auth-filesystem-wait-retention/reproduce.cjsdocs/audits/auth-filesystem-wait-retention/settlement-order.cjsdocs/audits/auth-filesystem-wait-retention/source-versions.jsondocs/audits/auth-filesystem-wait-retention/sources.cjsdocs/audits/auth-filesystem-wait-retention/validation.jsonsrc/main/rate-limits/auth-filesystem-operation-retention.test.tssrc/main/rate-limits/auth-filesystem-operation.tssrc/shared/promise-settlement-waiters.test.tssrc/shared/promise-settlement-waiters.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Detach aborted auth waits —
createAuthFilesystemOperationnow routes each caller throughPromiseSettlementWaiters(result, onSettled)instead ofPromise.race([result, aborted]), so the shared raw promise keeps exactly one reaction and expired poll reasons are collectible; last-waiter cancellation and the ownershipwaitersset still fire from the returned promise's.finally. - Opt-in deferred abort settlement —
PromiseSettlementWaitOptions.abortInMicrotask(defaultfalse, so every existing registry consumer is unchanged) queues abandonment in aqueueMicrotask, reproducing the oldPromise.raceordering when abort and raw settlement share a turn.createAbortError/abandonwiden tounknownso arbitrary auth abort reasons survive. - Regression coverage — new
auth-filesystem-operation-retention.test.tsproves each abandoned poll's reason is GC-collectible while one native operation stays pending and that no extraresult.thenreaction is added; ordering cases added to thePromiseSettlementWaiterssuite. Tests rely on--expose-gc, whichconfig/vitest.config.tspins. - Portable proof —
docs/audits/auth-filesystem-wait-retention/**(reverse-patchfix.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.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Co-authored-by: m4air <[email protected]>

Problem and change
Repeated quota polls wait on the same unfinished filesystem request. Each abandoned
Promise.raceleaves 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
PromiseSettlementWaitersso 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
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.