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
Users who use LastPass can't use Next.JS app router pages with password fields #51816
Comments
Does the same issue occur under the pages/ directory? It looks like that LastPass modifies the DOM which causes React to fail to hydrate. |
No, it only happens in the app router. Here's a repro for pages/: |
The same thing happens to me since we've switched to the appdir, it's not that the users can't use the app, but it indeed triggers warnings all over the place. |
Interesting, I guess it's a race condition between LastPass and the next hydrator, if LastPass runs first then we get the error, if it runs second we don't. |
This is definitely a framework-level problem. There shouldn't be an issue where a site/app bugs out because an extension made an otherwise innocuous change to the DOM. We know extensions/userscripts/browsers sometimes make changes to pages in the background. If a framework can't handle that it's not production-ready. |
Basically Laspass tries to inject code into the DOM in username and password fields. I "solved" the problem by putting my login form in a non-SSR component. See example at https://blog.bitsrc.io/using-non-ssr-friendly-components-with-next-js-916f38e8992c |
Unfortunately hydration errors like this are triggered inside React, not Next.js (@pc-erin). This becomes more noticeable in the App Router because it uses React 18+ with strict mode always enabled:
So if an extension tries to modify the DOM structure, it might cause that problem. The workaround is to add the This problem is being tracked in React's repo: facebook/react#24430 (someone mentioned the LastPass issue as well). I'll close this one in Next.js. |
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. |
Verify canary release
Provide environment information
Operating System: Platform: linux Arch: x64 Version: #23-Ubuntu SMP PREEMPT_DYNAMIC Wed May 17 16:55:20 UTC 2023 Binaries: Node: 19.9.0 npm: 9.6.7 Yarn: N/A pnpm: N/A Relevant Packages: next: 13.4.8-canary.2 eslint-config-next: 13.4.5 react: 18.2.0 react-dom: 18.2.0 typescript: 5.1.3 Next.js Config: output: N/A
Which area(s) of Next.js are affected? (leave empty if unsure)
App directory (appDir: true)
Link to the code that reproduces this issue or a replay of the bug
https://codesandbox.io/p/sandbox/modest-jang-tv3w5v?file=%2Fapp%2Fpage.tsx%3A1%2C1
To Reproduce
Describe the Bug
Users with LastPass installed on the browser get a hydration error on pages which LastPass autofills:
Expected Behavior
The page should hydrate properly without causing errors and a page failure.
This issue has been discussed on the GitHub but the only suggested resolution has been to disable LastPass on the form, which is pretty unsustainable given how many users would expect LastPass to work on NextJS sites. I don't think the issue is on LastPass's end either as I think it's fair to assume on their end that manipulating the DOM trivially is OK.
There are also reports of similar but less dire issues with Grammarly and Loom, which are also very popular browser extensions.
The conclusion to draw, I think, is that Next.JS needs to be more flexible/tolerant of DOM manipulation and attempt to handle it. Especially when it's this trivial of a manipulation. Users won't understand why the site is broken and developers are going to be coming across this issue very frequently.
Which browser are you using? (if relevant)
Irrelevant but Google Chrome 114.0.5735.133
How are you deploying your application? (if relevant)
This occurs in local development
The text was updated successfully, but these errors were encountered: