#parsing error for tanstack-start convex and clerk (initialized from the cli

8 messages · Page 1 of 1 (latest)

iron star
#

g [Error]: The value [object Response] of type "object" cannot be parsed/serialized.

There are few workarounds for this problem:

  • Transform the value in a way that it can be serialized.
  • If the reference is present on multiple runtimes (isomorphic), you can use the Reference API to map the references.
    at G.parseObject (file:///home/solo/Documents/codingProjects/Weaver/node_modules/seroval/dist/esm/production/index.mjs:17:31059)
    at G.parse (file:///home/solo/Documents/codingProjects/Weaver/node_modules/seroval/dist/esm/production/index.mjs:17:31430)
    at G.parseProperties (file:///home/solo/Documents/codingProjects/Weaver/node_modules/seroval/dist/esm/production/index.mjs:17:32428)
    at G.parsePlainObject (file:///home/solo/Documents/codingProjects/Weaver/node_modules/seroval/dist/esm/production/index.mjs:17:28700)
    at G.parseObject (file:///home/solo/Documents/codingProjects/Weaver/node_modules/seroval/dist/esm/production/index.mjs:17:29897)
    at G.parse (file:///home/solo/Documents/codingProjects/Weaver/node_modules/seroval/dist/esm/production/index.mjs:17:31430)
    at G.parseItems (file:///home/solo/Documents/codingProjects/Weaver/node_modules/seroval/dist/esm/production/index.mjs:17:27974)
    at G.parseArray (file:///home/solo/Documents/codingProjects/Weaver/node_modules/seroval/dist/esm/production/index.mjs:17:28031)
    at G.parseObject (file:///home/solo/Documents/codingProjects/Weaver/node_modules/seroval/dist/esm/production/index.mjs:17:29705)
    at G.parse (file:///home/solo/Documents/codingProjects/Weaver/node_modules/seroval/dist/esm/production/index.mjs:17:31430) {
    value: Response { routerCode: 'BEFORE_LOAD' }
    }
modern graniteBOT
#

Hi @iron star. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

The error you're seeing, The value [object Response] of type "object" cannot be parsed/serialized, typically occurs when a non-serializable object (like a native Response object) is returned or passed through a serialization boundary in TanStack Start, Convex, or Clerk integration. This is a common issue when using server functions or loaders that accidentally return a raw Response object instead of plain JSON-serializable data.

What causes this?

  • In TanStack Start, server functions (like those created with createServerFn) must return data that can be serialized (plain objects, strings, numbers, etc.), not native objects like Response.
  • Accidentally returning or passing a Response object (for example, from fetch or a server handler) will trigger this error.

How to fix it:

  • Ensure that your server functions and loaders only return serializable data. If you use fetch or similar APIs, extract the data you need (e.g., with .json() or .text()) and return that instead of the raw Response.
  • Double-check your beforeLoad and any server function handlers to make sure you are not returning a Response object.

Example fix:
If you have something like this in your server function:

const fetchClerkAuth = createServerFn({ method: 'GET' }).handler(async () => {
  const auth = await getAuth(getWebRequest());
  const token = await auth.getToken({ template: 'convex' });

  // Don't return a Response object!
  // return new Response(JSON.stringify({ userId: auth.userId, token }));

  // Instead, return a plain object:
  return {
    userId: auth.userId,
    token,
  };
});

Make sure you are not returning a Response object anywhere in your server-side code.

#

Related context:

  • This is a known issue when integrating Clerk, Convex, and TanStack Start, especially in the beforeLoad function or server functions. The solution is always to ensure only serializable data crosses the boundary between server and client or between different runtimes. If you need to handle a Response, always extract the data you need and return that instead of the raw object Clerk, convex, tanstack-start error.

If you continue to see this error, review all your server functions and loaders for any accidental return of non-serializable objects. If you need more specific help, please share the relevant code snippet where the error occurs.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@iron star Kapa.ai is still learning and improving, please let me know how I did by reacting below.

iron star
#

const fetchClerkAuth = createServerFn({ method: 'GET' }).handler(async () => {
const request = getWebRequest()
if (!request) throw new Error('No request found')

const auth = await getAuth(getWebRequest())
const token = await auth.getToken({ template: 'convex' })

return {
userId: auth.userId,
token,
}
})

this is my function why do i still have the error

#

@modern granite

modern graniteBOT
#

Let me check the knowledge base for you again. One moment! :books: