Skip to content

Return an error from Node::disconnect if removing the peer fails - #1211

Open
Ansh-699 wants to merge 1 commit into
lightningdevkit:mainfrom
Ansh-699:2026-10-disconnect-remove-peer-error
Open

Ansh-699 wants to merge 1 commit into
lightningdevkit:mainfrom
Ansh-699:2026-10-disconnect-remove-peer-error

Conversation

@Ansh-699

Copy link
Copy Markdown
Contributor

Fixes #1210.

Node::disconnect only logged a failure to remove the peer from the peer store and returned Ok(()), so we'd keep reconnecting to a peer the caller was told had been removed. It now still disconnects the current session, but returns the error so the caller can retry.

The new test only fails writes to the peer list. For that, NamespaceWriteFailingStore can now be limited to a single key, like ContendedStore already can, as the peer list shares the empty namespace with the ChannelManager and the event queue. #1149 adds a similar peer-only store, so whichever of the two lands second can reuse the other.

One thing I left as is: remove_peer also writes when the peer isn't stored, so with a failing store disconnect now also returns an error for a peer that was never persisted. Avoiding that would mean changing remove_peer, which #1175 rewrites, so I kept it out of this PR.

AI-assisted: written with help from Claude.

`Node::disconnect` only logged a failure to remove the peer from the
peer store and then returned `Ok(())`. As `PeerStore::remove_peer`
keeps the peer when its write fails, we'd keep reconnecting to a peer
the caller was told had been removed, including after a restart.

We now still disconnect the current session, but return the error, so
the caller can retry.

AI-assisted: written with help from Claude.
@ldk-reviews-bot

ldk-reviews-bot commented Oct 27, 2026 •

Copy link
Copy Markdown

I've assigned @tnull as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

@ldk-reviews-bot
ldk-reviews-bot requested a review from tnull October 27, 2026 13:29
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.

Return an error from Node::disconnect if removing the peer fails

2 participants