-
Notifications
You must be signed in to change notification settings - Fork 880
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add support for bigint #970
Changes from all commits
a8c5e7e
d01cb27
c594f4c
5584d58
3632ee3
0822130
eb64c0d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -509,6 +509,52 @@ test('handles objects with null prototype', async ({ same }) => { | |
}) | ||
}) | ||
|
||
test('normalize bigint to string', async ({ same }) => { | ||
const stream = sink() | ||
const instance = pino(stream) | ||
const bigInt = 1n | ||
instance.info({ bigInt }) | ||
const result = await once(stream, 'data') | ||
delete result.time | ||
same(result, { | ||
pid, | ||
hostname, | ||
level: 30, | ||
bigInt: `${bigInt.toString()}n` | ||
}) | ||
}) | ||
|
||
test('normalize nested object with bigint to string', async ({ same }) => { | ||
const stream = sink() | ||
const instance = pino(stream) | ||
const bigInt = { a: { b: 1n } } | ||
instance.info({ bigInt }) | ||
const result = await once(stream, 'data') | ||
delete result.time | ||
same(result, { | ||
pid, | ||
hostname, | ||
level: 30, | ||
bigInt: { a: { b: '1n' } } | ||
}) | ||
}) | ||
|
||
test('object and format bigInt property', async ({ same }) => { | ||
const stream = sink() | ||
const instance = pino(stream) | ||
instance.info({ answer: 42n, foo: { bar: BigInt(Number.MAX_SAFE_INTEGER) + 10n } }, 'foo %s', 1n) | ||
const result = await once(stream, 'data') | ||
delete result.time | ||
same(result, { | ||
pid, | ||
hostname, | ||
level: 30, | ||
msg: 'foo 1', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why doesn't this have the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tbh idk. is it important? would you like me to add the suffix? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The other outputs in this PR have the suffix. I'm asking about it from a consistency standpoint. How will an interpreter know that it is a |
||
answer: '42n', | ||
foo: { bar: '9007199254741001n' } | ||
}) | ||
}) | ||
|
||
test('pino.destination', async ({ same }) => { | ||
const tmp = join( | ||
os.tmpdir(), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going to slow us down significanfly. I'm -1 to us landing this feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The deep object benchmarks confirm this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have you checked the case then JSON.strigify throws an error? I bet it goes down a lot.
and -{a lot of users} because luck of bigint support.
––––
I guess it's possible to cofigure pino to skip bigint check. does it sound fine for you guys?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the pull request. We have had a discussion and have determined that
BigInt
needs better support in general. This implementation negatively impacts our benchmarks even when aBigInt
is not present.