From 95a7e8301c1480a5a7b72ecacf338f5a6fe31159 Mon Sep 17 00:00:00 2001 From: Guillaume Ballet Date: Wed, 18 Dec 2019 16:39:47 +0100 Subject: [PATCH] Fix RPC return value handling error --- console/bridge.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/console/bridge.go b/console/bridge.go index 220ed77d0e..826b24e1ad 100644 --- a/console/bridge.go +++ b/console/bridge.go @@ -440,7 +440,14 @@ func (b *bridge) Send(call goja.FunctionCall) (response goja.Value) { // raw message for some reason. resp.Set("result", goja.Null()) } else { - resultVal, err := b.runtime.RunString(string(result)) + + JSON := b.runtime.Get("JSON").ToObject(b.runtime) + parse, callable := goja.AssertFunction(JSON.Get("parse")) + if !callable { + panic("JSON.parse isn't a function") + } + + resultVal, err := parse(goja.Null(), b.runtime.ToValue(string(result))) if err != nil { setError(resp, -32603, err.Error()) } else {