From 777ea261c6e458328f3d03c453ab089aaa206518 Mon Sep 17 00:00:00 2001 From: fofolee Date: Tue, 30 Jun 2020 21:17:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=89=A7=E8=A1=8CuToolsapi?= =?UTF-8?q?=E6=97=B6Unable=20to=20deserialize=20cloned=20=E7=9A=84?= =?UTF-8?q?=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/node_modules/vm2/lib/contextify.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/node_modules/vm2/lib/contextify.js b/src/node_modules/vm2/lib/contextify.js index 573da44..805b600 100644 --- a/src/node_modules/vm2/lib/contextify.js +++ b/src/node_modules/vm2/lib/contextify.js @@ -616,7 +616,15 @@ Contextify.function = (fnc, traps, deepTraps, flags, mock) => { // Set context of all arguments to host's context. args = Decontextify.arguments(args); - try { + try { + // fix 'Unable to deserialize cloned data due to invalid or unsupported version' error of utools api + if (typeof context == 'object') { + var keys = Object.keys(context) + if (keys.includes('ubrowser') || keys.includes('goto')) { + args = args.map(a => (typeof a == 'object') && JSON.parse(JSON.stringify(a)) || a) + } + } + // end of fix return Contextify.value(fnc.apply(context, args)); } catch (e) { throw Contextify.value(e);