Next.js: SSG circular reference errors beginning with upgrade to 9.3

Created on 9 Mar 2020  路  3Comments  路  Source: vercel/next.js

Bug report

Describe the bug

I'm currently using Next 9.2.3 with unstable_getStaticProps and Contentful without any issues. I attempted to upgrade to 9.3 now that SSG has been finalized and released.

Doing so, however, gives me a Reason: Circular references cannot be expressed in JSON. without any code changes. My data does have some circular references in it, but I go out of my way to remove them using fast-safe-stringify when the data is fetched via Contentful.

What changed between 9.2.3 and 9.3? Is it possible to tell Next to ignore the result of the circular reference test if I'm sure the data is serializable, as it was in 9.2.3?

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Use unstable_getStaticProps with 9.2.3
  2. Upgrade to 9.3
  3. Rename unstable_getStaticProps to getStaticProps
  4. See error

Expected behavior

Page renders successfully in 9.3 as it does in 9.2.3

Screenshots

image

System information

  • Version of Next.js: 9.3

Most helpful comment

Looks like the issue is fixed in 9.3.1-canary.0 and the page renders successfully. Closing.

All 3 comments

Looks like the issue is fixed in 9.3.1-canary.0 and the page renders successfully. Closing.

Note this means you're emitting duplicate data and may be able to trim some bundle size!

But yes, this was fixed in canary. 鉂わ笍

Hi. I just went through this on getStaticProps with latest next@canary (9.5.3-canary.25). I've solved it with decycle/retrocycle functions after reading about them on MDN.

import { decycle, retrocycle } from "cycle";

export default function Page({ entry }) {
  const fineEntry = retrocycle(entry);
  // ...
}

export async function getStaticProps() {
  const entry = decycle(cycledEntry);
  return {
    props: {
      entry,
    },
  };
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

knipferrc picture knipferrc  路  3Comments

irrigator picture irrigator  路  3Comments

wagerfield picture wagerfield  路  3Comments

timneutkens picture timneutkens  路  3Comments

pie6k picture pie6k  路  3Comments