Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[legacy-framework] Deserialize SuperJSON-ed pageProps before passing to dehydratedState #2281

Merged
merged 11 commits into from
May 10, 2021

Conversation

Skn0tt
Copy link
Member

@Skn0tt Skn0tt commented Apr 29, 2021

Closes: blitz-js/legacy-framework#89

What are the changes and their implications?

When pageProps is accessed, it's required to deserialize its contents before using them.

Bug Checklist

  • Integration test added (see test docs if needed)

Feature Checklist

@Skn0tt
Copy link
Member Author

Skn0tt commented Apr 29, 2021

@MrLeebo do you want to add an integration test to this?

Copy link
Member

@MrLeebo MrLeebo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can set up an integration test, probably tonight.

packages/core/src/blitz-app-root.tsx Outdated Show resolved Hide resolved
@MrLeebo
Copy link
Member

MrLeebo commented May 2, 2021

@Skn0tt Added a test for this. If you inspect the server rendered output from the integration test, (via running blitz dev in test/integration/auth) you'll notice it renders the suspense fallback server-side but renders the results without re-fetching on the first client-side render. I also tested this with #1940 merged in, and was getting the fully rendered output from the server render, so once these two PRs are merged, prefetching will be a lot more viable in blitz.


function Bomb() {
useEffect(() => {
throw new Error("💣")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Skn0tt
Copy link
Member Author

Skn0tt commented May 4, 2021

Updated to the new babel-plugin-superjson-next and exclued dehydratedState.

Comment on lines 1514 to 1519
;[].forEach.call(webpackConfig.module.rules, function (
rule: webpack.RuleSetRule
) {
if (!(rule.test instanceof RegExp && Array.isArray(rule.use))) {
return
}
;[].forEach.call(
webpackConfig.module.rules,
function (rule: webpack.RuleSetRule) {
if (!(rule.test instanceof RegExp && Array.isArray(rule.use))) {
return
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we revert all the changes to the nextjs/* files? Not sure how this happened, but it will cause merge conflicts with the fork.

@flybayer
Copy link
Member

flybayer commented May 4, 2021

And you have a build error

@Skn0tt Skn0tt requested a review from flybayer May 8, 2021 08:02
@flybayer flybayer merged commit cf428bb into canary May 10, 2021
@flybayer flybayer deleted the fix-2280 branch May 10, 2021 20:31
@nimashoghi
Copy link

I'm currently playing around with query prefetching, and my query results include date objects. In this case, I receive a serialization error as this object is being handled by next.

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.

@flybayer
Copy link
Member

@nimashoghi oops — can you open a new issue for that?

@itsdillon itsdillon changed the title Deserialize SuperJSON-ed pageProps before passing to dehydratedState [legacy-framework] Deserialize SuperJSON-ed pageProps before passing to dehydratedState Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SuperJSON babel plugin causes prefetched queryKeys to miss the cache
5 participants