Skip to content

Only sessions on main state are active#711

Open
chm-diederichs wants to merge 8 commits intomainfrom
inherit-inactive-session
Open

Only sessions on main state are active#711
chm-diederichs wants to merge 8 commits intomainfrom
inherit-inactive-session

Conversation

@chm-diederichs
Copy link
Contributor

No description provided.

@chm-diederichs chm-diederichs changed the title Session inherits activity from parent Only sessions on main state are active Jul 31, 2025
Copy link
Contributor

@HDegroote HDegroote left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some questions, but I don't fully get the context of the PR and the consequences of refusing connections when we're not downloading, so needs a review by someone else too


if (this.destroyed) return
if (downloading || this._notDownloadingLinger === 0) {
if (downloading || this._notDownloadingLinger === 0 || !this.peers.length) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sanity check: isn't the point of having this._notDownloadingLinger that we postpone switching off the downloading a bit? We seem to override that check when this.peers.length === 0

}

_makePeer (protomux) {
if (!this.downloading) return false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs some thought, because I think it could be dangerous. Doesn't this mean we will never open replication sessions to peers if we're not downloading the hypercore ourselves?

So the underlying assumption is: we always have this.downloading set to true when we open a connection and actually want to replicate.

For example, this assumes there's no path where we open a connection to a peer while this.downloading === false but set it to true later.

(not saying this isn't correct, it just rings some alarm bells of 'potentially dangerous'. The fact that all tests pass does seem like a good sign)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ya true, we should add a test that checks if an inactive peer can replicate with an active peer if we dont

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.

4 participants