Skip to content

Fix ChannelClosingFailed flake in lsps2_service_prunes_closed_channel_state - #1257

Open
Jolah1 wants to merge 1 commit into
lightningdevkit:mainfrom
Jolah1:fix-lsps2-prune-test-close-race
Open

Jolah1 wants to merge 1 commit into
lightningdevkit:mainfrom
Jolah1:fix-lsps2-prune-test-close-race

Conversation

@Jolah1

@Jolah1 Jolah1 commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1256.

The test closes the JIT channel right after the client's PaymentReceived, while the client may still be persisting the monitor updates for settling the HTLC it just claimed. LDK won't begin a cooperative shutdown while a
monitor update is in flight, so close_channel occasionally fails with ChannelClosingFailed. The test now retries the close until the updates are through, polling for up to INTEROP_TIMEOUT_SECS like it already does for the
pruning. Retrying is safe, as LDK returns this error before changing any channel state.

This is the same race do_channel_full_cycle works around with the 1s sleep before its cooperative close, added in b088b35 when we switched to deferred monitor writes.

Testing: with the client's monitor writes temporarily delayed so the close lands inside the window, the test failed 3/3 without the change and passed 3/3 with it (details in the issue). All lsps2 integration tests pass.

Co-authored with Claude Code

@ldk-reviews-bot

ldk-reviews-bot commented Nov 24, 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.

The client closes its JIT channel right after `PaymentReceived`, while it
may still be persisting the monitor updates for settling the HTLC it just
claimed. LDK won't begin a cooperative shutdown while a monitor update is
in flight, so under load `close_channel` failed with
`ChannelClosingFailed`. Retry it until the updates are through, polling
like the test already does for the pruning.

This change was written with the assistance of Claude Code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Jolah1
Jolah1 force-pushed the fix-lsps2-prune-test-close-race branch from 9405a02 to ad5a05c Compare November 24, 2026 07:02
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.

Flaky lsps2_service_prunes_closed_channel_state: cooperative close races in-flight monitor updates

2 participants