Skip to content

wasm: detailed rpc logs #110

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

Merged
merged 1 commit into from
Feb 25, 2025
Merged

wasm: detailed rpc logs #110

merged 1 commit into from
Feb 25, 2025

Conversation

jbrill
Copy link
Contributor

@jbrill jbrill commented Feb 19, 2025

RPC Debug Improvements for WASM Client

Problem

When attempting to call new RPC methods, the frontend would hang without providing any useful debugging information, making it difficult to diagnose issues with RPC registration and execution.

Solution

Enhanced the logging and debugging capabilities of the WASM client's RPC system by:

  1. Adding comprehensive logging for RPC method validation and execution
  2. Adding visibility into the available RPC methods in the registry
  3. Improving error messages with more context

Changes

  • Added debug logging to show all available RPC methods in the registry when an RPC call is attempted
  • Enhanced error logging for RPC validation checks
  • Added panic recovery with stack traces for RPC execution
  • Improved logging for both successful and failed RPC calls

Testing

To test these changes:

  1. Set debug level logging
  2. Attempt to call both existing and non-existing RPC methods
  3. Verify that the registry contents are printed in the logs
  4. Verify that failed RPC calls now provide meaningful error messages

You should see a log in the console like the following:

2025-02-19 10:08:51.187 [ERR] WASM: RPC method 'litrpc.Status.NewRPC' not found in registry. 

Notes

These changes are purely diagnostic and do not modify any functional behavior of the WASM client.

@jbrill jbrill self-assigned this Feb 19, 2025
Copy link
Contributor

@ViktorTigerstrom ViktorTigerstrom left a comment

Choose a reason for hiding this comment

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

Awesome investigation 🚀! The PR looks good, just leaving a few line length comments that needs to be addressed, as we aim to wrap lines at 80 chars.

Great work 🎉🚀!

@jbrill
Copy link
Contributor Author

jbrill commented Feb 20, 2025

Awesome investigation 🚀! The PR looks good, just leaving a few line length comments that needs to be addressed, as we aim to wrap lines at 80 chars.

Great work 🎉🚀!

Perfect! Thanks for the review 😄 pushed up those line length modifications!

Copy link
Contributor

@ViktorTigerstrom ViktorTigerstrom left a comment

Choose a reason for hiding this comment

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

LGTM 🚀!

@jbrill jbrill merged commit f3a06e6 into master Feb 25, 2025
5 checks passed
@ellemouton
Copy link
Member

@jbrill - we usually wait for 2 ACKs before merging things

Comment on lines +330 to 331
"parameters: rpcName, request, callback")
return js.ValueOf("invalid use of wasmClientInvokeRPC, " +
Copy link
Member

Choose a reason for hiding this comment

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

nit: new line above return

return js.ValueOf("invalid use of wasmClientInvokeRPC, " +
"need 3 parameters: rpcName, request, callback")
}

if w.lndConn == nil {
log.Errorf("Attempted to invoke RPC but connection is not "+
"ready")
Copy link
Member

Choose a reason for hiding this comment

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

same

@@ -340,16 +344,29 @@ func (w *wasmClient) InvokeRPC(_ js.Value, args []js.Value) interface{} {

method, ok := w.registry[rpcName]
if !ok {
log.Errorf("RPC method '%s' not found in registry", rpcName)
return js.ValueOf("rpc with name " + rpcName + " not found")
Copy link
Member

Choose a reason for hiding this comment

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

same

return js.ValueOf("rpc with name " + rpcName + " not found")
}

go func() {
defer func() {
Copy link
Member

Choose a reason for hiding this comment

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

have we seen such panics happen?

jsCallback.Invoke(js.ValueOf(err.Error()))
} else {
log.Debugf("RPC '%s' succeeded with result: %s",
Copy link
Member

Choose a reason for hiding this comment

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

would Trace make more sense?

@guggero guggero deleted the rpc-debug-logs branch February 25, 2025 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants