Skip to content

tests: fix test_grpc_custommsg_notification flake#9154

Open
cdecker wants to merge 2 commits into
ElementsProject:masterfrom
cdecker:fix/grpc-custommsg-notification-flake
Open

tests: fix test_grpc_custommsg_notification flake#9154
cdecker wants to merge 2 commits into
ElementsProject:masterfrom
cdecker:fix/grpc-custommsg-notification-flake

Conversation

@cdecker
Copy link
Copy Markdown
Member

@cdecker cdecker commented May 20, 2026

Problem

test_grpc_custommsg_notification was flaky (example failure: https://github.com/ElementsProject/lightning/actions/runs/26100805227/job/76753937004).

Root Cause

After SubscribeCustomMsg() returns on the Python side, the gRPC server-side handler (subscribe_custom_msg in cln-grpc/src/server.rs) runs asynchronously in the Rust async runtime. It creates a broadcast::Receiver by calling self.events.subscribe(), which only receives events published after registration. If sendcustommsg fires before the handler has registered the receiver, the notification is broadcast with no listeners and is permanently lost.

Fix

test_grpc_connect_notification already has this exact fix (and a FIXME comment explaining it): wait for 'plugin-cln-grpc: received settings ACK' in the node log before triggering the event. This string is emitted by the h2 HTTP/2 library (used internally by tonic) when the server receives the client's SETTINGS_ACK frame — guaranteeing the full connection handshake is complete and the subscription receiver is live.

Apply the same synchronization barrier to test_grpc_custommsg_notification.

Lagrang3 and others added 2 commits May 7, 2026 12:18
Changelog-Added: askrene: askrene-remove-channel-update, a new RPC to remove channel_update entries from layers.

Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
The test was missing the same synchronization barrier that
test_grpc_connect_notification already has: after calling
SubscribeCustomMsg() on the Python side the gRPC server-side
subscribe_custom_msg() handler runs asynchronously, so the
broadcast::Receiver is not yet registered when the event fires.

Waiting for 'plugin-cln-grpc: received settings ACK' (emitted by the
h2 HTTP/2 layer on receipt of the client's SETTINGS_ACK frame) ensures
the full connection handshake has completed and the subscription is
live before we trigger the custommsg.
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.

2 participants