Skip to content

Require a multithreaded runtime when setting up the node - #1071

Open
elnosh wants to merge 1 commit into
lightningdevkit:mainfrom
elnosh:runtime-err-check
Open

Require a multithreaded runtime when setting up the node#1071
elnosh wants to merge 1 commit into
lightningdevkit:mainfrom
elnosh:runtime-err-check

Conversation

@elnosh

@elnosh elnosh commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

We already note on Node::start that we require the outer runtime to be of the multithreaded flavor, but we never check it.
Given that this block_in_place panics if called from a current-thread runtime, it seems we should error rather than just silently allow it.

https://docs.rs/tokio/latest/tokio/task/fn.block_in_place.html#panics

@ldk-reviews-bot

ldk-reviews-bot commented Aug 27, 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.

@ldk-reviews-bot
ldk-reviews-bot requested a review from tnull August 27, 2026 22:28

@tnull tnull left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yeah, I guess it's better to be explicit about it. One comment though.

Comment thread src/builder.rs Outdated
///
/// Note we require the given runtime to be of the `multithreaded` flavor.
#[cfg_attr(feature = "uniffi", allow(dead_code))]
pub fn set_runtime(&mut self, runtime_handle: tokio::runtime::Handle) -> &mut Self {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we return a new BuildError if the given handle does not belong to a multithreaded runtime?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

We already note on `Node::start` that we require the outer runtime to be
of the multithreaded flavor, but we never check it. We should, as our
synchronous API methods enter the runtime via `block_in_place`, which
panics on current-thread runtimes.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.

3 participants