Closed edgarasben closed 3 years ago
Hi @edgarasben! I tried updating our example to Next 11 in #78, and it works fine both locally and in CI. Could you provide a minimal reproduction repo? That'd make it a lot easier for me to reproduce.
Same happening to me.
There is not much to my use. Just a next.js page with the following getServerSideProps. .babel.rc is the example one, user has a datetime field
I just hit this problem and was trying your pkg, and come here for help because it was not working.
Error: Error serializing
.users[0].emailVerified
returned fromgetServerSideProps
in "/usuarios". Reason:object
("[object Date]") cannot be serialized as JSON. Please only return JSON serializable data types.This error happened while generating the page. Any console logs will be displayed in the terminal window.
export const getServerSideProps: GetServerSideProps = async () => {
const prisma = new PrismaClient()
const users = await prisma.user.findMany()
console.log(users)
return {
props: { users },
}
}
Exactly what @tadeumaia described. I can try to post a minimal reproduction repo later.
A repro would be great, thank you!
I have not work issue, but fixed by change plugins: ["superjson-next"]
to plugins: ["babel-plugin-superjson-next"]
That sounds like a caching issue then. @edgarasben @tadeumaia have you tried deleting caches?
That sounds like a caching issue then. @edgarasben @tadeumaia have you tried deleting caches?
@Skn0tt am not an advanced developer, could you specify what do you mean by that in this case?
I was running into issues as well when upgrading to Next v11 where it would no longer catch undefined
prop values from getServerSideProps
. This worked without issue in 10.2.3.
We're running with Express server and defined the working directory when initializing NextJS (const app = nextJS({ dir: './src' });
).
When we removed dir
parameter (src/pages
is supported by default in Next), this resolved our issue with SuperJSON not processing.
Not entirely sure if that is helpful, but could be a starting point to look at issues with custom directories?
could you specify what do you mean by that in this case?
Sure! Babel plugins such as babel-plugin-superjson-next
transpile your code. For efficiency, they try to cache their work: If a piece of code has been transpiled once, it won't be transpiled again. Sometimes this means stale caches: Something changed so you'd want everything to be re-transpiled again, but it doesn't since it's cached. Deleting caches is the easiest way to work around this.
For Next applications, deleting the .next
folder should be the easiest way to delete caches.
but could be a starting point to look at issues with custom directories?
A reproduction repository would be a great starting point.
Had the same issue and can confirm that deleting .next
folder a.k.a cleaning the cache helps to solve this :)
Closing this, as it seems to be fixed by purging the cache :)
@Skn0tt sorry for the late reply. When it did not work I removed the script from my codebase. But most likely you are right. It's the old .next cache that might have caused the problem. I will try using the script in the future and report here again, in case the problems persist.
Seems like this stopped working for me when updated to Next 11.0.0.
Did anybody run into a similar issue?