blitz-js / blitz-js/legacy-framework
Dehydrated state serialization error
- Dominant language
- JavaScript
- Stars
- 3
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
### What is the problem?
blitz-js/blitz#2281 made a change which makes it so that dehydratedState gets serialized using the default NextJS serialization method. This causes an error when we try to pass along data that is not JSON serializable (e.g., Date objects).
### Paste all your error logs here:
```
Error: Error serializing `.dehydratedState.queries[0].state.data.items[0].createdAt` returned from `getServerSideProps` in "/projects".
Reason: `object` ("[object Date]") cannot be serialized as JSON. Please only return JSON serializable data types.
```
### Paste all relevant code snippets here:
See https://blitzjs.com/docs/query-usage#prefetching
### What are detailed steps to reproduce this?
1. Create a query that returns a date.
2. Using the SSR prefetching setup from the docs, set up getServerSideProps to prefetch this query.
3. Load up the page and you should get this error.
### Run `blitz -v` and paste the output here:
```
Linux 5.11 | linux-x64 | Node: v16.0.0
blitz: 0.35.0-canary.6 (local)
Package manager: yarn
System:
OS: Linux 5.11 Debian GNU/Linux 10 (buster) 10 (buster)
CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
Memory: 8.40 GB / 31.20 GB
Shell: 7.1.3 - /usr/bin/pwsh
Binaries:
Node: 16.0.0 - /tmp/yarn--1621538252299-0.4332932868507675/node
Yarn: 1.22.5 - /tmp/yarn--1621538252299-0.4332932868507675/yarn
npm: 7.10.0 - /usr/local/bin/npm
Watchman: Not Found
npmPackages:
@prisma/client: 2.22.1 => 2.22.1
blitz: 0.35.0-canary.6 => 0.35.0-canary.6
prisma: 2.22.1 => 2.22.1
react: 0.0.0-experimental-6a589ad71 => 0.0.0-experimental-6a589ad71
react-dom: 0.0.0-experimental-6a589ad71 => 0.0.0-experimental-6a589ad71
typescript: 4.2.4 => 4.2.4
```
### Please include below any other applicable logs and screenshots that show your problem:
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.