after upgrading next 13 to 15, I encountered an issue, the streamed text doesn't get fully displayed.
I call a server action in useMutation (ReactQuery). in my server action, I used to return the whole response and it used to work correctly, but since I upgraded nextjs, it gave me this error:
[ Server ] Error: Only plain objects, and a few built-ins, can be passed to Client Components from Server Components. Classes or null prototypes are not supported.
{}
I return an object:
const response = await fetch(
`${process.env.NEXT_PUBLIC_SUPABASE_URL!}/functions/v1/send-message`,
{
method: 'POST',
headers: {
Authorization: `Bearer ${accessToken ?? ''}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
content,
}),
},
);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return {
body: response.body,
status: response.status,
headers: {
MSG: response.headers.get('MSG'),
},
};
} catch (error) {
console.error('sendMessage error: ', error);
throw error;
}
};