fix(admin): clear pending callbacks on ACL timeout/response — stop the leak (review AD-1/CS-2) #51
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/admin-pending-leak"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes the AD-1/CS-2 (and folds in AD-2) findings from the transport review.
The leak
requestPermission(the interactive admin-approval flow) sends asendRequestto each admin npub and registers a response callback intransport.pending. Two gaps:resolve(undefined)but neverclearPending→ every timed-out approval orphaned its pending entry permanently;Each orphaned entry retains a closure over
remotePubkey/keyName/method/ the JSON-serializedsign_eventpayload, so growth tracked signing traffic. It's a memory leak, not a key/signing/data issue, and scoped to the admin-DM auth path (requestPermissiononly runs when no webbaseUrlis configured — the demo usesbaseUrl, so it's dormant there).Fix
finish()resolves once and clears all of them — on both timeout and the first response.settledlatch makes late/duplicate responses no-ops. This also fixes AD-2: a late'always'approval can no longer runallowAllRequestsFromKey(persisting an ACL allow) after the request already timed out.nip19.decodeso a malformed admin npub skips that admin instead of throwing through the loop.transport.pendingat 1000 (evict oldest) so any other un-cleared path can't grow it without limit (an evicted entry would time out client-side anyway).tscat baseline; daemon bundles; admin + nip46 suites green.Refs: transport review AD-1 / CS-2 / AD-2; #42
🤖 Generated with Claude Code
47a5071b4aedf1ddc7da