-
Notifications
You must be signed in to change notification settings - Fork 22
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -326,11 +326,15 @@ func (w *wasmClient) Status(_ js.Value, _ []js.Value) interface{} { | |
|
||
func (w *wasmClient) InvokeRPC(_ js.Value, args []js.Value) interface{} { | ||
if len(args) != 3 { | ||
log.Errorf("Invalid use of wasmClientInvokeRPC, need 3 "+ | ||
"parameters: rpcName, request, callback") | ||
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") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
return js.ValueOf("RPC connection not ready") | ||
} | ||
|
||
|
@@ -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") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
} | ||
|
||
go func() { | ||
defer func() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. have we seen such panics happen? |
||
if r := recover(); r != nil { | ||
errMsg := fmt.Sprintf("Panic in RPC call: "+ | ||
"%v", r) | ||
log.Errorf("%s\n%s", errMsg, debug.Stack()) | ||
jsCallback.Invoke(js.ValueOf(errMsg)) | ||
} | ||
}() | ||
|
||
log.Infof("Calling '%s' on RPC with request %s", | ||
rpcName, requestJSON) | ||
cb := func(resultJSON string, err error) { | ||
if err != nil { | ||
log.Errorf("RPC '%s' failed: %v", rpcName, err) | ||
jsCallback.Invoke(js.ValueOf(err.Error())) | ||
} else { | ||
log.Debugf("RPC '%s' succeeded with result: %s", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would Trace make more sense? |
||
rpcName, resultJSON) | ||
jsCallback.Invoke(js.ValueOf(resultJSON)) | ||
} | ||
} | ||
|
@@ -358,7 +375,6 @@ func (w *wasmClient) InvokeRPC(_ js.Value, args []js.Value) interface{} { | |
<-ctx.Done() | ||
}() | ||
return nil | ||
|
||
} | ||
|
||
func (w *wasmClient) GetExpiry(_ js.Value, _ []js.Value) interface{} { | ||
|
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.
nit: new line above return