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.