iway1 / trpc-panel

MIT License
627 stars 43 forks source link

BigInt crashes frontend with `TypeError: BigInt value can't be serialized in JSON`. #55

Closed ben-xD closed 1 year ago

ben-xD commented 1 year ago

Thanks for this library! It's great for productivity - I'm just getting started.

I get an error in the browser when the API returns an object that contains a BigInt. For example, the JSON looks like:

[{"result":{"data":{"json":[{"id":"bob","createdAt":{"seconds":"1680535620","nanos":737587000}}],"meta":{"values":{"0.createdAt.seconds":["bigint"]}}}}}]

I'm using superjson. It looks like both superjson and trpc-panel are documented to support BigInt. However, returning BigInt causes the app to go into a full white screen.

Do you know what I can try to fix this?

Thanks 🙏

CleanShot 2023-04-03 at 16 53 08

iway1 commented 1 year ago

makes sense that this is happening, the return value of the procedure gets passed to JSON.stringify(). Definitely want to fix this, will need to use something else for converting the response into a string.

going to switch over to use https://www.npmjs.com/package/json-bigint to fix I think

iway1 commented 1 year ago

should be fixed in new version

ben-xD commented 1 year ago

Thanks a lot! 🙏