From ed7624e4f92e80e0dd76c1378a98e6ebd387db44 Mon Sep 17 00:00:00 2001 From: Justin Litchfield Date: Thu, 9 Jun 2022 10:23:41 -0500 Subject: [PATCH] Warning added to PLUGIN documentation re: `stdin` Adds some warning/documentation about the `println!`/`dbg!` causing my bad times as a plugin developer. =) --- doc/PLUGINS.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/doc/PLUGINS.md b/doc/PLUGINS.md index d12e5ae9d..553ca1051 100644 --- a/doc/PLUGINS.md +++ b/doc/PLUGINS.md @@ -22,6 +22,18 @@ used as protocol on top of the two streams, with the plugin acting as server and `lightningd` acting as client. The plugin file needs to be executable (e.g. use `chmod a+x plugin_name`) +### Warning + +As noted, `lightningd` uses `stdin` as an intake mechanism. This can +cause unexpected behavior if one is not careful. To wit, care should +be taken to ensure that debug/logging statements must be routed to +`stderr` or directly to a file. Activities that are benign in other +contexts (`println!`, `dbg!`, etc) will cause the plugin to be killed +with an error along the lines of: + +`UNUSUAL plugin-cln-plugin-startup: Killing plugin: JSON-RPC message +does not contain "jsonrpc" field` + ## A day in the life of a plugin During startup of `lightningd` you can use the `--plugin=` option to