fix: skip custom message WebSocket subscription for REST-based backends at startup#3948
fix: skip custom message WebSocket subscription for REST-based backends at startup#3948myxmaster wants to merge 1 commit intoZeusLN:masterfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request implements lazy subscription for custom messages, specifically targeting backends that use REST for LSPS1 but require custom messages for LSPS7 fallback. It also introduces a sentinel to prevent duplicate subscriptions. Feedback was provided regarding the need to reset this sentinel in the event of a WebSocket error to ensure that transient failures do not permanently block future subscription attempts.
fb6e946 to
25c6abb
Compare
|
|
|
Updated the PR description for clarity. You're right that |
|
Not sure this is worth the added complexity, especially when we're considering refactoring the wallet startup calls out of Wallet.tsx and into the individual backends. |
|
Fair point. If that is on the near-term roadmap, let's close this and let the refactor handle it cleanly instead. |
Description
When connecting to an LND REST wallet while an embedded-lnd wallet config also exists, a spurious
subscribeCustomMessagesWebSocket error appeared in the debug output.For LND REST and LNC, LSPS1 uses the REST API and LSPS7 uses custom messages only as a fallback when channels with the LSP already exist. The WebSocket subscription to /v1/custommessage/subscribe is therefore not needed unconditionally at startup.
Changes:
Wallet.tsx: only callsubscribeCustomMessagesat startup for backends that use custom messages for LSPS1 (!supportsLSPS1rest())getExtendableChannels()for backends using the custom message LSPS7 fallback (LND REST, LNC), and only when a channel with the LSP actually existssubscribeCustomMessages: setcustomMessagesSubscriber = truein the non-embedded-lnd branch so the deduplication guard works correctly; ; reset it toundefinedon WebSocket error so a subsequent retry is possible; fix error logging (errorinstead oferror.message)This pull request is categorized as a:
Checklist
yarn run tscand made sure my code compiles correctlyyarn run lintand made sure my code didn’t contain any problematic patternsyarn run prettierand made sure my code is formatted correctlyyarn run testand made sure all of the tests passTesting
If you modified or added a utility file, did you add new unit tests?
I have tested this PR on the following platforms (please specify OS version and phone model/VM):
I have tested this PR with the following types of nodes (please specify node version and API version where appropriate):
On-device
Remote
Locales
Third Party Dependencies and Packages
yarnafter this PR is merged inpackage.jsonandyarn.lockhave been properly updatedOther: