Skip to content

Commit

Permalink
fix: handle BigInt serialization (#512)
Browse files Browse the repository at this point in the history
  • Loading branch information
harelmo-lumigo authored Sep 4, 2024
1 parent 3803c0c commit 918dadd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/utils/payloadStringify.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,12 @@ export const payloadStringify = (
const type = typeof value;
const isObj = type === 'object';
const isStr = type === 'string';
const isBigInt = type === 'bigint';

if (isBigInt) {
return value.toString();
}

const shouldSkipSecretScrub =
skipScrubPath &&
skipScrubPath[skipScrubPath.length - 1] === key &&
Expand Down
6 changes: 6 additions & 0 deletions src/utils/payloadStringify.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ describe('payloadStringify', () => {
expect(result).toEqual('');
});

test('handles BigInt', () => {
const result = payloadStringify({ some: BigInt(345) });

expect(result).toEqual('{"some":"345"}');
});

test('payloadStringify -> truncate all', () => {
const payload = { a: 2, b: 3 };

Expand Down

0 comments on commit 918dadd

Please sign in to comment.