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

[NEXT-611] Improve hydration error messages in pages #46226

Closed
1 task done
chavda-bhavik opened this issue Feb 22, 2023 · 4 comments
Closed
1 task done

[NEXT-611] Improve hydration error messages in pages #46226

chavda-bhavik opened this issue Feb 22, 2023 · 4 comments

Comments

@chavda-bhavik
Copy link

chavda-bhavik commented Feb 22, 2023

Verify canary release

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

Provide environment information

    Operating System:
      Platform: linux
      Arch: x64
      Version: #33~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Jan 30 17:03:34 UTC 2
    Binaries:
      Node: 18.13.0
      npm: 8.19.3
      Yarn: 1.22.19
      pnpm: 7.9.4
    Relevant packages:
      next: 13.1.7-canary.21
      eslint-config-next: N/A
      react: 18.2.0
      react-dom: 18.2.0

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

No response

Link to the code that reproduces this issue

https://github.com/chavda-bhavik/nextjs-error-reproduction

To Reproduce

  1. Write this invalid jsx in the index.tsx file,
export default function Home() {
  return (
    <button>
      <button>Click Me</button>
    </button>
  );
}
  1. See the error Hydration failed because the initial UI does not match what was rendered on the server.
    image

Describe the Bug

I am receiving the Hydration failed because the initial UI does not match what was rendered on the server error when attempting to troubleshoot an HTML issue in jsx. It would be helpful to have a more specific error message that indicates which HTML element the issue is in, as this would make it easier to identify what the problem is.

Expected Behavior

When there is an issue in jsx regarding HTML, a message stating issue in HTML would be helpful to debug rather than the Hydration failed because the initial UI does not match what was rendered on the server error. In addition to where the HTML issue is.

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

NEXT-611

@chavda-bhavik chavda-bhavik added the bug Issue was opened via the bug report template. label Feb 22, 2023
@icyJoseph
Copy link
Contributor

icyJoseph commented Feb 22, 2023

Typically the console contains the exact node where things went wrong. Do remember that this is first and foremost a React error.

Screenshot 2023-02-22 at 09 29 35

There's however a question, I used to agree too but now I don't know, should this really... break onto a hydration error? #36765

The error did exist when React 17 was used under the hood, but now with the concurrent root, this kind of things breaks the hydration process. facebook/react#24519

@chavda-bhavik
Copy link
Author

Thanks for the clarification, Joseph. I think we are talking about the same thing, does it really a hydration error or not?

@timneutkens
Copy link
Member

We've changed the error overlay in a bunch of ways recently: facebook/react#24519 (comment)

@balazsorban44 balazsorban44 changed the title Need better error message for HTML issues Need better error message for HTML issues in pages Feb 22, 2023
@balazsorban44 balazsorban44 changed the title Need better error message for HTML issues in pages Improve hydration error messages in pages Feb 22, 2023
@balazsorban44 balazsorban44 changed the title Improve hydration error messages in pages [NEXT-611] Improve hydration error messages in pages Feb 22, 2023
@balazsorban44 balazsorban44 removed the bug Issue was opened via the bug report template. label Feb 22, 2023
@github-actions
Copy link
Contributor

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 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants