sveltekit-chat
sveltekit-chat copied to clipboard
Data returned from action inside / is not serializable: Cannot stringify arbitrary non-POJOs
Hello,
I tried to copy what you are doing with the ReadableStream :
const example_stream_rows = [/* examples */]
const readable: ReadableStream = new ReadableStream<string>({
async start(controller) {
for (const row of example_stream_rows) {
console.log("PUSHING", row);
controller.enqueue(row);
}
console.log("CLOSING");
controller.close();
}
});
and
return new Response(readable, {
headers: { 'Content-Type': 'text/plain' },
})
but I am getting:
Error: Data returned from action inside / is not serializable: Cannot stringify arbitrary non-POJOs
at try_deserialize (/workspaces/app/node_modules/@sveltejs/kit/src/runtime/server/page/actions.js:286:10)
at stringify_action_response (/workspaces/app/node_modules/@sveltejs/kit/src/runtime/server/page/actions.js:268:9)
at Module.handle_action_json_request (/workspaces/app/node_modules/@sveltejs/kit/src/runtime/server/page/actions.js:71:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async resolve (/workspaces/app/node_modules/@sveltejs/kit/src/runtime/server/respond.js:409:18)
at async Module.respond (/workspaces/app/node_modules/@sveltejs/kit/src/runtime/server/respond.js:282:20)
at async file:///workspaces/app/node_modules/@sveltejs/kit/src/exports/vite/dev/index.js:502:22
Have you encountered something similar ?
Are you returning the stream from an action? At the moment, SvelteKit only supports returning streams from server routes (+server.ts)
oh my god ! You saved my day ! Thank you so much, it now works ! 🎉