Skip to content

fix: destroy the replication streams a store created when it closes - #187

Open
danielAsaboro wants to merge 2 commits into
holepunchto:mainfrom
danielAsaboro:fix/close-destroys-replication-streams
Open

danielAsaboro wants to merge 2 commits into
holepunchto:mainfrom
danielAsaboro:fix/close-destroys-replication-streams

Conversation

@danielAsaboro

Copy link
Copy Markdown

store.close() leaves streams made by store.replicate(true) / store.replicate(false) open, and they stay in streamTracker. If such a stream is piped to a socket, the socket outlives the store. StreamTracker.destroy() already skips external streams and destroys the rest, but nothing calls it. v6 destroyed these streams on close; the call was lost in the V7 rewrite.

The root store now calls this.streamTracker.destroy() in _close before closing the cores. Streams passed in (store.replicate(socket)) are external and left alone, as before.

The replicate helper in test/groups.js waited for 'close' on both streams in teardown. When the store's own teardown closes it first, that event has already fired. It now skips streams that are already destroyed.

validation

The new test in test/basic.js closes a store with a live internal stream and waits for the stream's 'close'. Without the fix it never comes and the test does not end; with it, the stream is destroyed and untracked. 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 blocking issues remain.

Summary

The root store now destroys streams it created during close, while leaving caller-owned streams open.

  • Closing a store now closes the replication streams it created.

Reviews (2) · Last reviewed commit: "test that streams passed to replicate st..." · Reviewed by Greptile

Comment thread test/basic.js Resolved

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