You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to use Prisma and SvelteKit and when I try to return an object or array of objects with a property with a decimal value I get the following error:
Error: Data returned from load while rendering / is not serializable: Cannot stringify arbitrary non-POJOs (propertyName)
[
{
id: 'e290ca8b-b763-4782-af1d-bc4b2f9160c4',
name: 'Mouse',
description: 'Mousey mouse',
price: 12.99
}
]
Error: Data returned from `load`while rendering / is not serializable: Cannot stringify arbitrary non-POJOs (data.products[0].price)
at get_data (C:/Users/ablesea/tempVscode/speltkit/shopapp/SvelteKit-Decimal-Errors/node_modules/.pnpm/@sveltejs+kit@1.25.0_svelte@4.2.0_vite@4.4.9/node_modules/@sveltejs/kit/src/runtime/server/page/render.js:580:9)
at Module.render_response (C:/Users/ablesea/tempVscode/speltkit/shopapp/SvelteKit-Decimal-Errors/node_modules/.pnpm/@sveltejs+kit@1.25.0_svelte@4.2.0_vite@4.4.9/node_modules/@sveltejs/kit/src/runtime/server/page/render.js:280:27)
.4.9/node_modules/@sveltejs/kit/src/runtime/server/page/index.js:295:10)
at async resolve (C:/Users/ablesea/tempVscode/speltkit/shopapp/SvelteKit-Decimal-Errors/node_modules/.pnpm/@sveltejs+kit@1.25.0_svelte@4.2.0_vite@4.4.9/node_modules/@sveltejs/kit/src/runtime/server/respond.js:415:18)
at async Module.respond (C:/Users/ablesea/tempVscode/speltkit/shopapp/SvelteKit-Decimal-Errors/node_modules/.pnpm/@sveltejs+kit@1.25.0_svelte@4.2.0_vite@4.4.9/node_modules/@sveltejs/kit/src/runtime/server/respond.js:282:20)
at async file:///C:/Users/ablesea/tempVscode/speltkit/shopapp/SvelteKit-Decimal-Errors/node_modules/.pnpm/@sveltejs+kit@1.25.0_svelte@4.2.0_vite@4.4.9/node_modules/@sveltejs/kit/src/exports/vite/dev/index.js:506:22
There is an existing issue #9401 for allowing custom serialization of data. If that's implemented, that's going to be your solution, because we can't serialize/deserialize arbitrary classes.
Describe the bug
I am trying to use Prisma and SvelteKit and when I try to return an object or array of objects with a property with a decimal value I get the following error:
Error: Data returned from
load
while rendering / is not serializable: Cannot stringify arbitrary non-POJOs (propertyName
)The object I am trying to return logs to this:
+page.server.ts
I can get around the issue by stringifying and parsing the object before I return it like this:
Prisma uses decimal.js for its decimals it could be causing a conflict. Reference: https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields#working-with-decimal
Prisma Discussion:
prisma/prisma#19063
Reproduction
Repo: https://github.com/ieedan/SvelteKit-Decimal-Errors
You can comment and uncomment the return statements in +page.server.ts
Logs
System Info
Severity
serious, but I can work around it
Additional Information
No response
The text was updated successfully, but these errors were encountered: