Skip to content

Commit 4ae4fea

Browse files
committed
fix: properly handle cyclic objects
1 parent e4277e7 commit 4ae4fea

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"dependencies": {
5050
"@hawk.so/types": "^0.1.20",
5151
"error-stack-parser": "^2.1.4",
52+
"safe-stringify": "^1.1.1",
5253
"vite-plugin-dts": "^4.2.4"
5354
}
5455
}

src/addons/consoleCatcher.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*/
44

55
import type { ConsoleLogEvent } from '@hawk.so/types';
6+
import safeStringify from 'safe-stringify';
67

78
const createConsoleCatcher = (): {
89
initConsoleCatcher: () => void;
@@ -69,7 +70,7 @@ const createConsoleCatcher = (): {
6970
method,
7071
timestamp: new Date(),
7172
type: method,
72-
message: args.map((arg) => typeof arg === 'string' ? arg : JSON.stringify(arg)).join(' '),
73+
message: args.map((arg) => typeof arg === 'string' ? arg : safeStringify(arg)).join(' '),
7374
stack,
7475
fileLine: stack.split('\n')[0]?.trim(),
7576
};

yarn.lock

+5
Original file line numberDiff line numberDiff line change
@@ -2619,6 +2619,11 @@ safe-regex-test@^1.0.3:
26192619
es-errors "^1.3.0"
26202620
is-regex "^1.1.4"
26212621

2622+
safe-stringify@^1.1.1:
2623+
version "1.1.1"
2624+
resolved "https://registry.yarnpkg.com/safe-stringify/-/safe-stringify-1.1.1.tgz#f4240f506d041f58374d6106e2a5850f6b1ce576"
2625+
integrity sha512-YSzQLuwp06fuvJD1h6+vVNFYZoXmDs5UUNPUbTvQK7Ap+L0qD4Vp+sN434C+pdS3prVVlUfQdNeiEIgxox/kUQ==
2626+
26222627
semver@^6.3.1:
26232628
version "6.3.1"
26242629
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4"

0 commit comments

Comments
 (0)