We’re currently experiencing some intermittent production errors, specifically a SyntaxError:
⨯ SyntaxError: Unexpected token 'I', "Infinite l"... is not valid JSON
at JSON.parse ()
at async I (/var/task/.next/server/chunks/2953.js:1:4573)
at async (/var/task/.next/server/chunks/2953.js:1:8204) {
digest: '2397332721'
}
The logs from Vercel are not particularly helpful, making troubleshooting challenging. We’ve tried a few assumptions, but none have worked so far. It’s difficult to make progress since it feels like navigating in the dark. The error doesn’t occur locally (even when building for production)—it only happens on Vercel (preview and production).
If anyone navigates to a different page than the page on which the error occurs, this issue is fixed for everyone. For example, if I face this issue on both my laptop and phone, I can navigate to /subpage on my phone to fix it, which will also solve the issue on my laptop. Maybe it is some caching issue?
It looks like an endpoint somewhere in the app is expected to return JSON but instead returns something else (likely a non-json-formatted error message). Possibly related to caching or initial app state.
If the error only ever occurs on one page, then a try/catch and console.log() could help you get more info in the runtime logs. Please give that a try and let me know what new details come up
We were using the code-hike/bright package for code syntax highlighting, but replacing it with shiki (another syntax highlighting package) appears to have resolved the issue.
The infinite loop error appears to stem from the logic within the _loadGrammar function.
I’ll keep an eye on it and let you know if the issue arises again.