Skip to content

Commit 6548ac9

Browse files
committed
only set isTruncated after JSON.parse
1 parent 99c8fcd commit 6548ac9

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/replay/src/coreHandlers/handleScope.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,11 @@ export function normalizeConsoleBreadcrumb(breadcrumb: Breadcrumb): Breadcrumb {
8686
const normalizedArg = normalize(arg, 7);
8787
const stringified = JSON.stringify(normalizedArg);
8888
if (stringified.length > CONSOLE_ARG_MAX_SIZE) {
89-
isTruncated = true;
9089
const fixedJson = fixJson(stringified.slice(0, CONSOLE_ARG_MAX_SIZE));
91-
return JSON.parse(fixedJson);
90+
const json = JSON.parse(fixedJson);
91+
// We only set this after JSON.parse() was successfull, so we know we didn't run into `catch`
92+
isTruncated = true;
93+
return json;
9294
}
9395
return normalizedArg;
9496
} catch {

0 commit comments

Comments
 (0)