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);