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

Error when building: Unexpected token u in JSON at position 0 #45515

Closed
1 task done
rijk opened this issue Feb 2, 2023 · 3 comments
Closed
1 task done

Error when building: Unexpected token u in JSON at position 0 #45515

rijk opened this issue Feb 2, 2023 · 3 comments
Labels
bug Issue was opened via the bug report template.

Comments

@rijk
Copy link

rijk commented Feb 2, 2023

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

npx next info

    Operating System:
      Platform: darwin
      Arch: arm64
      Version: Darwin Kernel Version 22.2.0: Fri Nov 11 02:06:26 PST 2022; root:xnu-8792.61.2~4/RELEASE_ARM64_T8112
    Binaries:
      Node: 16.18.1
      npm: 8.19.2
      Yarn: N/A
      pnpm: 7.26.3
    Relevant packages:
      next: 13.1.7-canary.2
      eslint-config-next: 13.1.1
      react: 18.2.0
      react-dom: 18.2.0

Which area(s) of Next.js are affected? (leave empty if unsure)

App directory (appDir: true)

Link to the code that reproduces this issue

https://github.com/rijk/repro-rsc-issue/tree/repro

To Reproduce

Run pnpm run build

Describe the Bug

I was tracking down another issue with Vercel support (requesting a certain page with RSC header returned an error 500). After updating my reproduction to Next canary it no longer wanted to build at all:

[==  ] info  - Generating static pages (4/13)SyntaxError: Unexpected token u in JSON at position 0
    at JSON.parse (<anonymous>)

Support engineer asked me to create an issue for it.

Expected Behavior

No error.

Which browser are you using? (if relevant)

Not relevant

How are you deploying your application? (if relevant)

Vercel

@rijk rijk added the bug Issue was opened via the bug report template. label Feb 2, 2023
@rijk
Copy link
Author

rijk commented Feb 6, 2023

All right, I've discovered this is caused by a conditional return in several head components. Adding return null to the end fixed the build issue.

As an aside (and why I'll leave this open although the original issue is fixed), while debugging I found that if a page does not have a generateStaticParams() (or returns [] from it), it is called with params like this:

{
  organization: '%5Borganization%5D',
  path: '%5Bpath%5D',
  lesson: '%5Blesson%5D'
}

Is this intentional? It strikes me as odd.

@ijjk
Copy link
Member

ijjk commented Feb 6, 2023

Hi, this is currently expected yes as we currently attempt prerendering the page with default params to test if it is static or not similar to the generation of fallback pages. We are investigating this behavior still though.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2023

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

No branches or pull requests

2 participants