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 }