Repository navigation
fix(daemon): drop a lease whose connection closed while its open waited - #81
Merged
Merged
Conversation
UnitTable.open() takes the connection's lease after awaiting the unit's creation, or another client's creation of the same unit. When the connection closed in that window, disconnected() had already run without the lease, so nothing dropped it and the unit stayed pinned. open() now drops such a lease as disconnected() would, reconnect grace and module released() hook included, and removes the closed connection's lease set. New contract SA-DAEMON-OPEN-LEASE, offered to Oh My Pi; realign at the next alignment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes a daemon bug in Oh My Pi that Codex found while reviewing #80. If a client's connection closes while its
openis still waiting for the unit to be created (its own creation, or another client's creation of the same unit),UnitTable.open()takes the lease afterdisconnected()has already run. Nothing ever drops that lease, so the unit stays pinned: it never idles out and keeps running until the daemon exits.Fix. It is marked as new contract
SA-DAEMON-OPEN-LEASE, one marker block inunits.ts. Right after#addLease, if the connection is closed,open()drops the lease the waydisconnected()would:#dropLease, which also runs the module'sreleased()hook;#addLeasehad recreated.Upstream. The same change was offered to Oh My Pi as can1357/oh-my-pi#20263. Both the ledger entry and the SCIENT.md row say to realign at the next alignment: retire the contract as upstreamed if Oh My Pi merges #20263, or replace it with Oh My Pi's own fix if they fix it differently.
Proof. The new owned test
test/scient/daemon-open-lease.test.tsdrivesUnitTablein-process with a fake module whoseopenwaits on a gate, so there is no timing dependence.leases1 vs 0, and 2 vs 1). With it they pass.Footprint. +1 marker block, +10 lines in 1 Oh My Pi file, plus 1 owned test.
Not in this PR. Codex found a similar pre-existing gap in Oh My Pi's LSP module:
acquirecan reserve a slot after its connection's disconnect hook ran, and the reservation expires after 30 s. That needs its own fix.Platforms: the daemon code is shared across platforms and the change has no platform branches. The test runs in-process wherever the daemon tests run.
🤖 Generated with Claude Code