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

Duplicated head tag after page load #36309

Closed
1 task done
jccots opened this issue Apr 20, 2022 · 6 comments
Closed
1 task done

Duplicated head tag after page load #36309

jccots opened this issue Apr 20, 2022 · 6 comments
Labels
bug Issue was opened via the bug report template. please add a complete reproduction The issue lacks information for further investigation

Comments

@jccots
Copy link

jccots commented Apr 20, 2022

Verify canary release

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

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP Wed Apr 13 20:24:50 UTC 2022
Binaries:
  Node: 16.9.1
  npm: 7.21.1
  Yarn: 1.22.17
  pnpm: N/A
Relevant packages:
  next: 12.1.6-canary.4
  react: 17.0.2
  react-dom: 17.0.2

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

yarn dev

Describe the Bug

We define some common head elements on document.tsx file, for instance...

<Head> <script async src={https://www.googletagmanager.com/gtag/js?id=someId
/>
<script
dangerouslySetInnerHTML...`

Then some other tags such as og:title as part of a component using next/head.

We noticed that after document reached a certain size-we added some additional scripts which were +200 lines long -, some tags, such as og:title, not defined on document tsx appear duplicated. Once we navigate to a new page, where the component updates, only one of them is updating. This happens for tags where we use key atribute as well, but not for all tags.

Expected Behavior

Only one og:title meta tag is created.

I wonder this is restricted to this only. Not sure if this is intended but I can see other duplicated tags added by the framework, such as charset and viewport.

To Reproduce

There is no clear pattern to reproduce unfortunately. On the local environment, a large document tsx creates more head element duplicates. We can see the duplicate viewport as well on nextjs.org site. Page loads with 1 viewport tag, but after load another one is added. For a large document tsx, I can also see other tags being duplicated, and only one of them being updated after changing page.

@jccots jccots added the bug Issue was opened via the bug report template. label Apr 20, 2022
@timneutkens timneutkens added the please add a complete reproduction The issue lacks information for further investigation label Apr 20, 2022
@timneutkens
Copy link
Member

Please add a complete reproduction repository.

@jccots
Copy link
Author

jccots commented Apr 20, 2022

ok, will try to create a reduced repo. Is it possible we are seeing the same on nextjs.org? i see some tags duplicated, chartset and viewport

@Lukydemboy
Copy link

We are experiencing the same behaviour. On the initial page load there is one og:title tag, but when we navigate to another page a og:title tag is added. When we then change pages again, only one is updated, the other tag keeps the old values.

@jccots
Copy link
Author

jccots commented May 6, 2022

We noticed the same behaviour. I am trying to get a simplifed repo to reproduce, but not straight forward it seems, not just related to the document.tsx i guess. But i can see a duplicated tag on nextjs.org page, with charset and viewport, not sure if the same root cause.
I think the duplicated tag is added later, by js. Same behaviour can be observed in https://nextjs.org/, viewport meta element added once on SSR, then once again on page load.

@jccots jccots changed the title Duplicated head tag on large document.tsx Duplicated head tag after page load May 11, 2022
@balazsorban44
Copy link
Member

This issue has been automatically closed because it received no activity for a month and had no reproduction to investigate. If you think this was closed by accident, please leave a comment. If you are running into a similar issue, please open a new issue with a reproduction. Thank you.

@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 Jul 13, 2022
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. please add a complete reproduction The issue lacks information for further investigation
Projects
None yet
Development

No branches or pull requests

4 participants