Repository navigation
tests: fix websocket connect races in test_clnrest - #9581
Open
daywalker90 wants to merge 1 commit into
Open
daywalker90 wants to merge 1 commit into
daywalker90 wants to merge 1 commit into
Conversation
Andezion
previously approved these changes
Sep 30, 2026
Andezion
left a comment
Collaborator
There was a problem hiding this comment.
Is there a trace or log showing that the CONNECT packet was really lost, and not just late? Also should we keep a client side check of the error text when connect_error does fire, so we dont lose coverage?
daywalker90
force-pushed
the
fix-test_websocket_no_rune
branch
from
September 30, 2026 11:03
aa84935 to
8119ef1
Compare
Collaborator
Author
|
I could not find a log for a lost case but this should cover both lost and late. |
Collaborator
Author
|
Added the error message coverage back in. |
Andezion
previously approved these changes
Sep 30, 2026
notifications_received_via_websocket() relied on the socketio client's connect_error callback and its default 1s wait_timeout to detect the namespace handshake result. In the flakes the server logged "Authorized rune" and "Socket.IO connected" well inside that window, yet the client raised socketio.exceptions.ConnectionError: One or more namespaces failed to connect: so the connect_error callback never fired and, for the rejection tests, the expected error was compared against an empty string, e.g. ValueError: Expected error code `Missing rune`, got `One or more namespaces failed to connect: ` instead Why the client does not process the server's namespace reply is not established: it could not be reproduced locally, and the engine.io upgrade path on both sides looks correct. So this works around it rather than fixing a root cause. This affected both the rejection tests (test_websocket_no_rune, test_websocket_wrong_rune, test_websocket_rune_no_listnotifications, test_websocket_upgrade_header) and the successful-connection tests (test_websocket_unrestricted_rune, test_websocket_rune_readonly, test_websocket_rune_listnotifications, test_numeric_msat_notification). Give the namespace handshake a longer timeout, disable the client's background reconnection and retry transient connect failures for the success path. Keep checking the exact text the server sent when the connect_error callback fires, and fall back to the node log when it does not. Also make test_websocket_upgrade_header fail if the connection unexpectedly succeeds, instead of falling through. Changelog-None
daywalker90
force-pushed
the
fix-test_websocket_no_rune
branch
from
October 1, 2026 16:33
8119ef1 to
6595b97
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
notifications_received_via_websocket() relied on the socketio client's connect_error callback and its default 1s wait_timeout to detect the namespace handshake result. Under CI load the namespace CONNECT reply is sometimes lost during the polling to websocket upgrade, so sio.connect() raises
socketio.exceptions.ConnectionError: One or more namespaces failed to
connect:
even though the server logged "Authorized rune" and "Socket.IO connected". The connect_error callback therefore never fired, so for the rejection tests the test compared the expected error against an empty string, e.g.
ValueError: Expected error code
Missing rune, gotOne or more namespaces failed to connect:insteadThis affected both the rejection tests (test_websocket_no_rune, test_websocket_wrong_rune, test_websocket_rune_no_listnotifications, test_websocket_upgrade_header) and the successful-connection tests (test_websocket_unrestricted_rune, test_websocket_rune_readonly, test_websocket_rune_listnotifications, test_numeric_msat_notification).
Give the namespace handshake a longer timeout, disable the client's background reconnection and retry transient connect failures for the success path. Check the node log for the expected rejection instead of the unreliable client-side error text.
Changelog-None
Fixes: #9561