IDs in webhook payloads get rounded down

shopify app webhook trigger sample payloads contain BigInts in the payloads (typically for ID fields) – these numbers get rounded down in Remix when getting the payload: const { payload } = await authenticate.webhook(request).

Are real payloads guaranteed to never have BigInts?

Otherwise, that’s a fairly significant bug, no?


More context:

JSON (or at least the Node implementation) cannot handle BigInts / large numbers – they get rounded down. I typically solve this using JSON.parse’s reviver function, which allows me to preserve the original value.

When handling Shopify webhooks in a Remix app, const { payload } = await authenticate.webhook(request)parses the body internally, and BigInts get rounded down.

Additionally, attempting to parse the body in a BigInt-compatible way before or after authenticating the request results in an error, as the body will have already been consumed, and can only be consumed once. This can be solved by cloning the request beforehand, and parsing the clone’s body.

Unless payloads are guaranteed to never contain BigInts, this is what I assume I’ll have to do – it just seems rather wasteful, especially if you’re handling a large volume of webhooks, whose payloads can oftentimes be quite big.

Hey @Tim_Johnson, looking at my production webhooks, when numeric IDs are sent they are below JavaScript’s MAX_SAFE_INTEGER limit (9,007,199,254,740,991). For context, fulfillment order IDs are in the 13-14 digit range, and when IDs appear in GID format they’re always strings.

Hey @Tim_Johnson, did the above help at all?

Hi @KyleG-Shopify – Thanks for your response – I’ll mark as a solution.

That being said, I do still wonder if they’re guaranteed to always be under that limit, or if it simply appears that way looking at various resource IDs.

That being said, I imagine if any IDs were above that limit, it’d probably cause myriad other problems throughout the platform, and thus would have been noticed. That this hasn’t happened is probably a good enough guarantee.

Thanks

1 Like

Thanks Tim. Yes, there are a lot of apps using the Remix template, so id’s above the limit would definitely cause a lot of problems.