Skip to content

Conversation

@starius
Copy link
Collaborator

@starius starius commented Nov 6, 2025

Change Description

From v0.20.0-rc3 (commit c6f458e) onward the ChainNotifier sub-server may still be initialising when clients attempt to subscribe, currently resulting in a gRPC Unknown error with a plain-text message. Change the notifier RPC endpoints to return codes.Unavailable instead so clients can reliably interpret the condition as "retry later" and handle the startup lag without unstable string matching.

Motivation

To ensure that Loop and other services wait for LND while it is starting up, lndclient was modified to retry when it encounters the "chain notifier RPC is still in the process of starting" error. @mohamedawnallah noted in the review that relying on matching error strings is not ideal. Using an error code on the other hand is more reliable. The purpose of this PR is to provide lndclient (and other clients) with a clear signal to retry the request. See lightninglabs/lndclient#253 (comment)

Steps to Test

Send RegisterBlockEpochNtfn while LND is starting and inspect the returned gRPC error code. It should be Unavailable.

Pull Request Checklist

Testing

  • Your PR passes all CI checks.
  • Tests covering the positive and negative (error paths) are included.
  • Bug fixes contain tests triggering the bug to prevent regressions.

Code Style and Documentation

📝 Please see our Contribution Guidelines for further guidance.

From v0.20.0-rc3 (commit c6f458e) onward
the ChainNotifier sub-server may still be initialising when clients attempt
to subscribe, currently resulting in a gRPC Unknown error with a plain-text
message. Change the notifier RPC endpoints to return codes.Unavailable instead
so clients can reliably interpret the condition as "retry later" and handle
the startup lag without unstable string matching.
@starius starius force-pushed the chainnotifier-unavallable branch from d6c3e8f to c165bae Compare November 7, 2025 00:59
starius added a commit to starius/lndclient that referenced this pull request Nov 7, 2025
lnd v0.20.0-rc3 delays ChainNotifier startup which causes Loop to hit
"chain notifier RPC is still in the process of starting" during initial
subscriptions (LND commit c6f458e478f9ef2cf1d394972bfbc512862c6707).
Add a shared retry helper in lndclient so block epoch, confirmation and spend
registrations transparently retry until the sub-server is ready, along with
regression tests covering the behaviour.

With lnd PR lightningnetwork/lnd#10352 the server now
returns gRPC codes.Unavailable instead of codes.Unknown, so the helper accepts
either signal (status code or a string).
starius added a commit to starius/lndclient that referenced this pull request Nov 7, 2025
lnd v0.20.0-rc3 delays ChainNotifier startup which causes Loop to hit
"chain notifier RPC is still in the process of starting" during initial
subscriptions (LND commit c6f458e478f9ef2cf1d394972bfbc512862c6707).
Add a shared retry helper in lndclient so block epoch, confirmation and spend
registrations transparently retry until the sub-server is ready, along with
regression tests covering the behavior.

With lnd PR lightningnetwork/lnd#10352 the server now
returns gRPC codes.Unavailable instead of codes.Unknown, so the helper accepts
either signal (status code or a string).
starius added a commit to starius/lndclient that referenced this pull request Nov 7, 2025
lnd v0.20.0-rc3 delays ChainNotifier startup which causes Loop to hit
"chain notifier RPC is still in the process of starting" during initial
subscriptions (LND commit c6f458e478f9ef2cf1d394972bfbc512862c6707).
Add a shared retry helper in lndclient so block epoch, confirmation and spend
registrations transparently retry until the sub-server is ready, along with
regression tests covering the behavior.

With lnd PR lightningnetwork/lnd#10352 the server now
returns gRPC codes.Unavailable instead of codes.Unknown, so the helper accepts
either signal (status code or a string).
Also fixed a typo in release notes.
@starius starius force-pushed the chainnotifier-unavallable branch from c165bae to e4313eb Compare November 7, 2025 02:03
@mohamedawnallah
Copy link
Contributor

mohamedawnallah commented Nov 7, 2025

Let's add motive behind that PR in the PR description. That can help give reviewers some context and perhaps getting some attraction. In other words referencing this: lightninglabs/lndclient#253 (comment)

@starius
Copy link
Collaborator Author

starius commented Nov 7, 2025

Let's add motive behind that PR in the PR description. That can help give reviewers some context and perhaps getting some attraction. In other words referencing this: lightninglabs/lndclient#253 (comment)

Great idea! I added Motivation section.

@starius starius marked this pull request as ready for review November 7, 2025 06:23
@starius starius changed the title [WIP] chainrpc: return Unavailable while notifier starts chainrpc: return Unavailable while notifier starts Nov 7, 2025
Copy link
Collaborator

@ziggie1984 ziggie1984 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you

Copy link
Collaborator

@ViktorT-11 ViktorT-11 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 🙏

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.

4 participants