Skip to content

fix: drop a core a peer opens mid-purge instead of failing the store's close - #185

Open
shavtvalishvili wants to merge 1 commit into
holepunchto:mainfrom
shavtvalishvili:fix/attach-purged-core
Open

shavtvalishvili wants to merge 1 commit into
holepunchto:mainfrom
shavtvalishvili:fix/attach-purged-core

Conversation

@shavtvalishvili

@shavtvalishvili shavtvalishvili commented Oct 27, 2026 •

Copy link
Copy Markdown

_attachMaybe checks storage.hasCore and then opens the core. If a purge() deletes the core between those two steps, core.ready() throws STORAGE_EMPTY, and the failed core stays in this.cores, so the next store.close() rejects with the same error.

Now a core that fails to open there is dropped from this.cores and the peer's open is ignored, as if the check had said the core was missing.

validation

The new test in test/purge.js stubs hasCore to report the purged core once, which simulates the race, and it fails without the fix (close() rejects with STORAGE_EMPTY). npm test (node and bare) passes 55/55, and npm run lint is clean.

We hit this on a peer that purges cores while other peers still replicate them, and we currently carry it as a patch on 7.12.6.

@shavtvalishvili
shavtvalishvili requested a review from a team October 27, 2026 14:22

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