Skip to content

fix: track sessions by discovery key so cores opened without a key are gc-ed - #188

Open
danielAsaboro wants to merge 1 commit into
holepunchto:mainfrom
danielAsaboro:fix/session-tracker-discovery-key
Open

danielAsaboro wants to merge 1 commit into
holepunchto:mainfrom
danielAsaboro:fix/session-tracker-discovery-key

Conversation

@danielAsaboro

Copy link
Copy Markdown

get() and _preload file a session under this.sessions.get(core.id). A core created from a discovery key has no key yet, so core.id is null until it opens. That covers get({ discoveryKey }) on a core that isn't loaded, and get({ name }) after a restart, where the alias lookup returns a discovery key. Those sessions go into a shared null bucket. _ongc later gcs by the real id, so the null bucket is never removed: store.sessions.size stays at 1 after every session is closed, and store.sessions.list() misses those sessions.

SessionTracker is now keyed by the hex discovery key, the same id CoreTracker uses, which is always known when the core is opened. The three existing assertions that called store.sessions.list(core.id) now pass the hex discovery key.

validation

The new test in test/basic.js reopens a store, gets a named core twice and closes both sessions. Without the fix, list() returns 0 sessions and sessions.size stays 1; with it, both sessions are tracked and the entry is removed. Node and Bare 55/55, npm run lint clean.

@danielAsaboro
danielAsaboro requested a review from a team November 3, 2026 20:00
@greptile-apps

greptile-apps Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

Tracks sessions by the hex discovery key instead of core.id, so tracking no longer depends on whether the public key has loaded.

  • Corestore tracks sessions under each core’s discovery key.

Reviews (1) · Last reviewed commit: "track sessions by discovery key" · Reviewed by Greptile

This branch has not been deployed

No deployments
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