From 0cc99703f95e733c8e279c5a081ec51ae9f1013b Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 28 Apr 2021 02:39:24 +0300 Subject: [PATCH] fix: vue3 support #4506 --- core/native-bridge.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/core/native-bridge.ts b/core/native-bridge.ts index 893ded94c2..ac8d40f77f 100644 --- a/core/native-bridge.ts +++ b/core/native-bridge.ts @@ -272,10 +272,19 @@ const initBridge = (w: any): void => { ); }; + const safeStringify = (value: any): string => { + const seen = new Set() + return JSON.stringify(value, (_k, v) => { + if (seen.has(v)) { return '...' } + if (typeof v === 'object') { seen.add(v) } + return v + }) + } + const serializeConsoleMessage = (msg: any): string => { if (typeof msg === 'object') { try { - msg = JSON.stringify(msg); + msg = safeStringify(msg); } catch (e) { // ignore }