Skip to content

Node is unsafe to drop in an async context #372

@tvolk131

Description

@tvolk131

The Drop implementation for Node calls Node::stop():

ldk-node/src/lib.rs

Lines 1748 to 1752 in 3f1c842

impl Drop for Node {
fn drop(&mut self) {
let _ = self.stop();
}
}

And Node::stop() blocks the runtime:

ldk-node/src/lib.rs

Lines 849 to 855 in 3f1c842

let timeout_res = runtime.block_on(async {
tokio::time::timeout(
Duration::from_secs(100),
event_handling_stopped_receiver.changed(),
)
.await
});

This makes it unsafe to drop a Node when running in an async context, leading to this issue in the Fedimint LDK lightning gateway.

This is a big foot-gun. We should be able to drop a Node in either a sync or async context.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions