posthog-js icon indicating copy to clipboard operation
posthog-js copied to clipboard

`rrweb logger error: TypeError: Do not know how to serialize a BigInt`

Open bitjson opened this issue 1 year ago • 5 comments

My application logs a complex object that contains some values of type BigInt. This works in the user's development console, but posthog-js@npm:1.101.0 returns the error:

rrweb logger error: TypeError: Do not know how to serialize a BigInt
    at JSON.stringify (<anonymous>)
    at Lt (/node_modules/rrweb/es/rrweb/packages/rrweb/src/plugins/console/record/stringify.js:56:17)
    at node_modules/rrweb/es/rrweb/packages/rrweb/src/plugins/console/record/index.js:112:53
    at Array.map (<anonymous>)
    at console.log (node_modules/rrweb/es/rrweb/packages/rrweb/src/plugins/console/record/index.js:112:42)

Is there some way to exclude this particular console.log from rrweb logging?

I'd love to be able to use something like window._posthogMasked.console.log (which could hold the un-instrumented console.log) for this particular logging statement.

bitjson avatar Jan 24 '24 23:01 bitjson

Screenshot 2024-01-24 at 23 26 34

Yep, bigint isn't json stringifiable

This would need to be fixed in rrweb downstream from us...

You can patch this in your environment... for example https://github.com/GoogleChromeLabs/jsbi/issues/30#issuecomment-1006088574

pauldambra avatar Jan 24 '24 23:01 pauldambra

Ah, and it's already a known issue there https://github.com/rrweb-io/rrweb/issues/1209

pauldambra avatar Jan 24 '24 23:01 pauldambra

fix proposed here https://github.com/rrweb-io/rrweb/pull/1403

pauldambra avatar Jan 25 '24 08:01 pauldambra

Fantastic, thanks @pauldambra! Looks like it was already merged into master there – any idea when that might land in posthog-js?

bitjson avatar Jan 25 '24 18:01 bitjson

I know the folk running rrweb are working on some issues before they can release their next version. So no timescale unfortunately. But we're excited for a few other fixes too so as soon as its available we'll move across

pauldambra avatar Jan 25 '24 19:01 pauldambra

That fix is now merged in rrweb, so this should be fine in latest versions

pauldambra avatar May 03 '24 09:05 pauldambra