Skip to content

Commit

Permalink
Revert "fix(bridge): Safely JSON.Stringify circular json on log (#4507)"
Browse files Browse the repository at this point in the history
This reverts commit e4c8fe4.
  • Loading branch information
thomasvidas authored May 6, 2021
1 parent e4c8fe4 commit 7cf79be
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions core/native-bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,15 +192,6 @@ const initBridge = (w: any): void => {
win.Ionic.WebView = IonicWebView;
};

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 initLogger = (win: WindowCapacitor, cap: CapacitorInstance) => {
const BRIDGED_CONSOLE_METHODS: (keyof Console)[] = [
'debug',
Expand Down Expand Up @@ -280,11 +271,11 @@ const initBridge = (w: any): void => {
typeof c.dir === 'function'
);
};

const serializeConsoleMessage = (msg: any): string => {
if (typeof msg === 'object') {
try {
msg = safeStringify(msg);
msg = JSON.stringify(msg);
} catch (e) {
// ignore
}
Expand Down Expand Up @@ -371,7 +362,7 @@ const initBridge = (w: any): void => {
// android platform
postToNative = data => {
try {
win.androidBridge.postMessage(safeStringify(data));
win.androidBridge.postMessage(JSON.stringify(data));
} catch (e) {
win?.console?.error(e);
}
Expand Down Expand Up @@ -401,7 +392,7 @@ const initBridge = (w: any): void => {
url: url,
line: lineNo,
col: columnNo,
errorObject: safeStringify(err),
errorObject: JSON.stringify(err),
},
};

Expand Down

0 comments on commit 7cf79be

Please sign in to comment.