TanStackT
TanStack4mo ago
7 replies
brilliant-orange

Typescript error with server functions with the GET method

I migrated successfully my app to RC, I have only one issue with server functions using the get method, like this one
export const getUserSession = createServerFn({
    method: 'GET',
}).handler(async () => {
    const request = getRequest();

    if (!request.headers) {
        return null;
    }

    const userSession = await auth.api.getSession({ headers: request.headers });

    return userSession;
});

now I have this error:
the types of 'options.query.unwrap' are incompatible between these types.
Type '(() => ZodObject<{ disableCookieCache: ZodOptional<ZodCoercedBoolean<unknown>>; disableRefresh: ZodOptional<ZodCoercedBoolean<unknown>>; }, $strip>) & (() => ZodObject<...>)' is not assignable to type '"Function is not serializable"'
Was this page helpful?