-
Notifications
You must be signed in to change notification settings - Fork 22
Fix WASM-client disconnection error #103
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
Conversation
9c9e76d
to
d1d5807
Compare
Updated the PR with adding a callback that's executed once the disconnection has completed, so that the frontend only updates once we're fully disconnected. I noticed that for checking wether we are connected or not, we instead use a ticker that checks the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice, LGTM 🎉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tACK 🚀
I've confirmed the disconnect issue is now fixed.
My only request would be to have some way to disable the additional logs that are now being outputted. It logs 2 lines every second which adds a lot of noise that isn't particularly useful info for us app devs. It makes it harder to read through our own logs. Could a config param be used to disable this?
Thanks a lot for the reviews @guggero & @jamaljsr! @jamaljsr, just wanted to check, is setting the But in a real setting when using the wasm-client, I'd imagine that the |
Ah yes, great suggestion about tweaking the
I prefer the callback approach over polling, so it looks good to me. My only nitpick would be to rename |
d1d5807
to
ff53bad
Compare
Awesome :rocket!
Great ok! I've renamed the callback to lightning-node-connect/example/index.html Lines 56 to 58 in d8c9f92
If you'd like me to do the same for the onDisconnect callback let me know, but I found this approach I've implemented in the PR a bit cleaner.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tACK LGTM 🚀
If you'd like me to do the same for the
onDisconnect
callback let me know, but I found this approach I've implemented in the PR a bit cleaner.
I like this approach as well.
cmd/wasm-client/main.go
Outdated
go func() { | ||
if err := w.lndConn.Close(); err != nil { | ||
log.Errorf("Error closing RPC connection: %v", err) | ||
} | ||
w.lndConn = nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it maybe worth using a wait group just to ensure that things do actually complete?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review and suggestion @ellemouton!
Unfortunately I did try that before, but using a WaitGroup
and then Wait
ing for the WaitGroup
at the end of the Disconnect
function makes the same problem that existed prior to the fix occur. The main thread then blocks on the Wait
and for some reason it never picks up that the Websocket
is now Hard closed by the new updates to the grpc
dependency (introduced in v0.18.1
). I think this is because this is in a JavaScript environment, and the main thread therefore never picks up any changes to the Javascript objects as it's blocking. So the WaitGroup
Wait
would never complete.
I therefore chose the alternative to signal the completion by a callback instead, as that unblocks the main thread, and makes it pick up the hard close of the Websocket. Hope that makes sense!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense! thanks for the explanation :)
Close the client connection in a goroutine. This fixes a bug that was introduced with the upgrade to grpc v0.18.1. The caused the websocket to freeze during closure when the client disconnected, and therefore the entire wasm-client would freeze. When closing the connection in a goroutine, the websocket is closed correctly.
ff53bad
to
58a5902
Compare
Just added some docs to the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tACK, LGTM!
Great investigation on this 👏 🏆
In this PR, we add a fix that solves the error that the wasm-client freezes when attempting to close the sockets when disconnecting.
I've also added a commit to add the
gbn
subsystem to the wasm-client's logger. This simplifies debugging errors quite a lot. Let me know if you don't think that commit is worth including though :)