Repository navigation
cln-plugin: do not drop JsonRpc::Error replies on select! cancellation - #9759
Open
daywalker90 wants to merge 1 commit into
Open
daywalker90 wants to merge 1 commit into
daywalker90 wants to merge 1 commit into
Conversation
…ation `PluginDriver::run` polled `self.dispatch_one(&mut input, &self.plugin)` inside `tokio::select!` alongside `receiver.recv()`. When `JsonRpc::Error` arrived, `dispatch_one` awaited `plugin.sender.send(rpc_error).await` on the bounded `mpsc::channel(4)`. If that channel was full, `receiver.recv()` won the `select!` and cancelled `dispatch_one`, silently dropping the `-32700` error reply and leaving `lightningd` waiting indefinitely for that request `id`. Poll `input.next()` directly in `tokio::select!` (which is cancel-safe), make message dispatching synchronous in `PluginDriver::dispatch_message` returning an optional immediate reply, and write `JsonRpc::Error` replies directly to `output` in `PluginDriver::run` (also avoiding self-deadlocking on a full `mpsc` channel). Add a regression test saturating the bounded `mpsc` channel while sending malformed JSON frames and verifying every `-32700` error reply is delivered. Changelog-Fixed: cln-plugin: prevent `JsonRpc::Error` replies from being silently dropped when the internal response channel is full.
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.
PluginDriver::runpolledself.dispatch_one(&mut input, &self.plugin)insidetokio::select!alongsidereceiver.recv(). WhenJsonRpc::Errorarrived,dispatch_oneawaitedplugin.sender.send(rpc_error).awaiton the boundedmpsc::channel(4). If that channel was full,receiver.recv()won theselect!and cancelleddispatch_one, silently dropping the-32700error reply and leavinglightningdwaiting indefinitely for that requestid.Poll
input.next()directly intokio::select!(which is cancel-safe), make message dispatching synchronous inPluginDriver::dispatch_messagereturning an optional immediate reply, and writeJsonRpc::Errorreplies directly tooutputinPluginDriver::run(also avoiding self-deadlocking on a fullmpscchannel).Add a regression test saturating the bounded
mpscchannel while sending malformed JSON frames and verifying every-32700error reply is delivered.Changelog-Fixed: cln-plugin: prevent
JsonRpc::Errorreplies from being silently dropped when the internal response channel is full.