fix(daemon): dispose late durable capture authorities - #2101
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes a durable-capture recovery resource leak in the daemon by ensuring late-arriving successful recovery authorities are disposed when the deadline/cancellation wins the Promise.race, while preserving the primary timeout/cancellation error and reporting cleanup failures via the existing callback seam.
Changes:
- Track which promise won the recovery race (acquisition vs deadline vs cancellation) and trigger late-success disposal only when the caller already timed out/canceled.
- Dispose late authorities with correct handle/control ordering (dispose active handle before control; dispose control only for non-active outcomes).
- Add/extend Vitest coverage for late-success disposal behavior and primary-error preservation when late cleanup fails.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/daemon/durable-capture-recovery-authority.ts | Adds race-winner tracking and a late-success disposal path for dropped recovery authorities. |
| src/daemon/tests/durable-capture-recovery-authority.test.ts | Adds tests covering late-success disposal (active + non-active) and ensuring cancellation remains the primary error when late cleanup fails. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| void acquisition.then( | ||
| (authority) => disposeLateRecoveryAuthority(params, authority, primaryError), | ||
| () => {}, | ||
| ); |
dae18ac to
948f4e4
Compare
948f4e4 to
49c5aa8
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (1)
src/daemon/durable-capture-recovery-authority.ts:120
- The late-cleanup path uses
void acquisition.then(...)without handling rejections from the cleanup callback. IfdisposeLateRecoveryAuthorityrejects (e.g., ifonLateCleanupFailurethrows), this can surface as an unhandled rejection even though it's best-effort cleanup after the primary deadline/cancellation error.
void acquisition.then(
(authority) => disposeLateRecoveryAuthority(params, authority, primaryError),
() => {},
);
|
Code-clean at |
|
The new acquisition-winner regression is useful and confirms caller ownership, but exact head |
|
Closing as superseded by #2107, which has merged to main. |
Summary
Closes #2099
Validation
pnpm check:affected --run: formatting, lint, typecheck, layering, Fallow, build, and related Vitest checks passed; 936 tests passed across 172 files.