Next.js Discord

Discord Forum

Weird json problem with SSR function after builidng my app

Unanswered
Cane Corso posted this in #help-forum
Open in Discord
Cane CorsoOP
Hey, for some reason after deploying my app to a docker container (it works well locally) one of the pages (page.tsx) that uses ssr with an async function, just doesnt work anymore, im getting this error:
[ERROR] Couldn't get all groups SyntaxError: Unexpected non-whitespace character after JSON at position 1221 (line 1 column 1222)
    at JSON.parse (<anonymous>)
    at parseJSONFromBytes (node:internal/deps/undici/undici:5477:19)
    at successSteps (node:internal/deps/undici/undici:5459:27)
    at fullyReadBody (node:internal/deps/undici/undici:4378:9)
    at async consumeBody (node:internal/deps/undici/undici:5468:7)
    at async /app/apps/frontend/.next/server/app/[locale]/(main)/(cs2)/music/page.js:6:5490
    at async b (/app/apps/frontend/.next/server/app/[locale]/(main)/(cs2)/(main)/page.js:1:22834)
    at async v (/app/apps/frontend/.next/server/app/[locale]/(main)/(cs2)/(main)/page.js:1:23024)

and sometimes:
[ERROR] Couldn't get all groups SyntaxError: Unexpected token 'a', "a:["$","di"... is not valid JSON
    at JSON.parse (<anonymous>)
    at parseJSONFromBytes (node:internal/deps/undici/undici:5477:19)
    at successSteps (node:internal/deps/undici/undici:5459:27)
    at fullyReadBody (node:internal/deps/undici/undici:4378:9)
    at runNextTicks (node:internal/process/task_queues:60:5)
    at listOnTimeout (node:internal/timers:540:9)
    at process.processTimers (node:internal/timers:514:7)
    at async consumeBody (node:internal/deps/undici/undici:5468:7)
    at async /app/apps/frontend/.next/server/app/[locale]/(main)/(cs2)/music/page.js:6:5490
    at async b (/app/apps/frontend/.next/server/app/[locale]/(main)/(cs2)/(main)/page.js:1:22834


code:
const Cs2Servers = async () => {
    const allGroups = await getGroups() // Not filtered groups
    
    // ...
}

/**
 * Get all groups as strings for the filters
 */
const getGroups = async () => {
    try {
        const { data: groups, error } = await eden.cs2['servers-groups'].list.get({ query: {} })
        console.log({ groups, error })
        if (error) {
            logError('Failed to get all groups', error)
            return []
        }

        return groups || []
    } catch (e) {
        logError("Couldn't get all groups", e)
        return []
    }
}

export default Cs2Servers


the eden function works well in other components and all it does is fetching the backend (which should work fine)

everything works well in my local pc, even after building both, but once im building it in the cloud it screw up

0 Replies