Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pyln: Plugin methods and hooks refuse to set results twice #4094

Merged

Conversation

cdecker
Copy link
Member

@cdecker cdecker commented Sep 25, 2020

We had a couple of instances where a plugin would be killed by lightningd
because we were returning a result of an exception twice, and it was hard to
trace down the logic error in the user plugin that caused that. This patch
adds a traceback the first time we return a result/exception, and raise an
exception with a stacktrace of the first termination when a second one comes
in.

This can still terminate the plugin, but the programmer gets a clear
indication where the result was set, and can potentially even recover from it.

Changelog-Added: pyln: Plugin method and hook requests prevent the plugin developer from accidentally setting the result multiple times, and will raise an exception detailing where the result was first set.

@cdecker cdecker self-assigned this Sep 25, 2020
@cdecker cdecker added this to the v0.9.2 milestone Sep 25, 2020
Copy link
Collaborator

@m-schmoock m-schmoock left a comment

Choose a reason for hiding this comment

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

lgtm
I added some improvement proposals... feel free to take or merge.

contrib/pyln-client/pyln/client/plugin.py Outdated Show resolved Hide resolved
contrib/pyln-client/tests/test_plugin.py Show resolved Hide resolved
@cdecker
Copy link
Member Author

cdecker commented Sep 29, 2020

Folded in @m-schmoock's excellent fixups 👍

@cdecker cdecker force-pushed the pyln-plugin-duplicate-result branch from f836ef9 to f042f27 Compare October 11, 2020 20:01
We had a couple of instances where a plugin would be killed by `lightningd`
because we were returning a result of an exception twice, and it was hard to
trace down the logic error in the user plugin that caused that. This patch
adds a traceback the first time we return a result/exception, and raise an
exception with a stacktrace of the first termination when a second one comes
in.

This can still terminate the plugin, but the programmer gets a clear
indication where the result was set, and can potentially even recover from it.

Changelog-Added: pyln: Plugin method and hook requests prevent the plugin developer from accidentally setting the result multiple times, and will raise an exception detailing where the result was first set.
@cdecker cdecker force-pushed the pyln-plugin-duplicate-result branch from f042f27 to 8dee4eb Compare October 13, 2020 15:45
@cdecker
Copy link
Member Author

cdecker commented Oct 13, 2020

ACK 8dee4eb

@cdecker cdecker merged commit b1aed93 into ElementsProject:master Oct 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants