next.js icon indicating copy to clipboard operation
next.js copied to clipboard

Enabling PPR causes HTTP 500 when scanned by bots

Open mwskwong opened this issue 1 year ago • 7 comments

Link to the code that reproduces this issue

https://github.com/mwskwong/http-500-when-visit-by-bot

To Reproduce

  1. Bootstrap a Next.js app with the CLI
  2. Enable PPR in the config file

Deployed version: https://http-500-when-visit-by-bot.vercel.app/

Current vs. Expected behavior

Current The app will throw a 500 error when it is scanned by social media bots, typically when sharing the link of the website on social media. Reproduced on LinkedIn, Twitter, and Facebook (also with their share debuggers respectively).

It seems that it's a hydration error, but I'm not sure why does it show up on the server log.

image

Expected It should not throw an error when the site is scanned by bot.

Verify canary release

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

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Home
Binaries:
  Node: 20.9.0
  npm: N/A
  Yarn: N/A
  pnpm: 8.14.1
Relevant Packages:
  next: 14.0.5-canary.56
  eslint-config-next: 14.0.5-canary.56
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.3.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

App Router

Which stage(s) are affected? (Select all that apply)

Vercel (Deployed), Other (Deployed)

Additional context

No response

mwskwong avatar Jan 14 '24 06:01 mwskwong

Update: Reddit, Discord, WhatsApp don't seem to be affected by this.

mwskwong avatar Jan 18 '24 07:01 mwskwong

I'm seeing this too. WhatsApp seems to be a problem for me. Twitter, Reddit, iMessage work. LinkedIn, WhatsApp not working. I opened a discussion regarding this too here before I saw this issue.

Is there a fix that can be done for this?

libhide avatar Jan 19 '24 18:01 libhide

As a side note: Leerob's site, which is also using PPR, suffers from the same issue.

mwskwong avatar Jan 29 '24 08:01 mwskwong

@leerob 👀

libhide avatar Jan 29 '24 10:01 libhide

I am not seeing an issue rendering social cards as mentioned for leerob.io.

Slack

CleanShot 2024-01-29 at 21 06 59@2x

LinkedIn

CleanShot 2024-01-29 at 21 07 59@2x

leerob avatar Jan 30 '24 03:01 leerob

I am not seeing an issue rendering social cards as mentioned for leerob.io.

Slack LinkedIn

Interesting, on LinkedIn, sharing home page for real is fine, but Post Inspector complaints.

https://www.linkedin.com/post-inspector/inspect/https:%2F%2Fleerob.io

Yet, for blog pages, which uses PPR for real, the issue is reproducible.

Screenshot_2024-01-30-11-31-03-040_com linkedin android-edit

Edit: Thinking of that, @leerob, the current behavior you experienced in LinkedIn may be due to LinkedIn caching the metadata. You may try to share the auto-generated deployment URL to verify that.

mwskwong avatar Jan 30 '24 03:01 mwskwong

I too have noticed that the previews work for the website itself (ratik.in in my case) but fail to work for the blog or any of the nested pages.

libhide avatar Jan 30 '24 10:01 libhide

Updated the OP

  1. Updated next to the latest canary version
  2. Added a branch that literally just removes the ppr flag, and the issue is not reproducible on it.
    • With PPR: https://http-500-when-visit-by-bot.vercel.app
    • Without PPR: https://http-500-when-visit-by-bot-git-feature-without-ppr-mwskwong.vercel.app

mwskwong avatar Feb 06 '24 07:02 mwskwong

Vercel seems to finally be able to show the full log, so here is one example of it.

Error: Expected the resume to render <j> in this slot but instead it rendered <A>. The tree doesn't match so React will fallback to client rendering.
    at nq (/var/task/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js:12:66996)
    at nJ (/var/task/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js:12:73075)
    at nz (/var/task/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js:12:71240)
    at nq (/var/task/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js:12:69426)
    at nJ (/var/task/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js:12:73075)
    at nU (/var/task/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js:12:51918)
    at nq (/var/task/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js:12:67235)
    at nJ (/var/task/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js:12:73075)
    at nU (/var/task/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js:12:51918)
    at nq (/var/task/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js:12:67235) {
  digest: '1647279640'
}

mwskwong avatar Feb 19 '24 12:02 mwskwong

Oh, adding www.partialprerendering.com as the reproduction.

https://www.linkedin.com/post-inspector/inspect/https:%2F%2Fwww.partialprerendering.com%2F

mwskwong avatar Feb 25 '24 03:02 mwskwong

@mwskwong Any luck with fixing this? Seems to still be an issue :/

libhide avatar Apr 24 '24 14:04 libhide

@mwskwong Any luck with fixing this? Seems to still be an issue :/

Nope. I don't think there is anything I can do from the user side, besides not using PPR.

mwskwong avatar Apr 25 '24 01:04 mwskwong

@mwskwong Any luck with fixing this? Seems to still be an issue :/

Nope. I don't think there is anything I can do from the user side, besides not using PPR.

Yeah, same.

@leerob Any chance you'd know what's up with this issue?

libhide avatar Apr 25 '24 09:04 libhide

As a reminder, PPR is still experimental. We are currently triaging and investigating other, higher requested bugs/features right now, but thank you for providing more details on this issue.

leerob avatar Apr 26 '24 16:04 leerob

Give the latest canary a shot, the issues you've experienced are likely to have been fixed recently.

wyattjoh avatar Jun 14 '24 12:06 wyattjoh

Give the latest canary a shot, the issues you've experienced are likely to have been fixed recently.

No, it doesn't. I updated the reproduction's dependencies and deployed it accordingly

Also, the behavior can be easily verified by just toggling the ppr flag.

mwskwong avatar Jun 14 '24 12:06 mwskwong

Thanks for the details @mwskwong, I was able to identify and resolve the issue on Vercel's end. Let us know if the problem re-occurs by opening a new issue!

wyattjoh avatar Jul 02 '24 21:07 wyattjoh

Can confirm that this is fixed for me too. Thanks, everyone involved!

libhide avatar Jul 02 '24 23:07 libhide

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

github-actions[bot] avatar Jul 17 '24 00:07 github-actions[bot]