Skip to content

SSR Hydration resulting in duplicate elements #2611

@Paul-Hebert

Description

@Paul-Hebert

Stencil version:

 @stencil/core@1.17.2

I'm submitting a:

[x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://stencil-worldwide.herokuapp.com/ or https://forum.ionicframework.com/

Current behavior:

When using the generated hydrate script in an SSR-rendered app some elements are incorrectly duplicated. (The blue square to the right of my button is a duplicated, empty button)

incorrect

Expected behavior:

Hydrated components would only render once.

correct

Steps to reproduce:

I've had trouble narrowing this down to a specific cause. You can reproduce it using this repo I put together: https://github.com/cloudfour/stencil-ssr-bug-reproduction

This is a simplified version of a project I'm working on which is why it is structured the way it is. I have a subdirectory housing my stencil components. Adjacent to that I have another subdirectory housing my express app. From the root directory you can run a number of commands.

In order to build my express app, I build my stencil components, copy the output into the express app, and then run the express app.

  1. Check out that repo
  2. Install dependencies for the components: cd stencil-components, npm i, cd .. (from root)
  3. Install dependencies for my app: cd express-app, npm i, cd .. (from root)
  4. Build my components and copy them into my express app npm run build (from root)
  5. Run my express app: npm run start:express (from root)
  6. Navigate to express app (http://localhost:3000/)
  7. See that the button has been duplicated

I had also reproduced this using the prerender option in my project, but didn't set up a sample repository for that. Let me know if that would be helpful.

Related code:

See repro directory above

Other information:

I originally reported this as a comment on #2366 . @peterpeterparker was kind enough to take a look and help me debug it. He suggested a change to vdom-annotations which seemed to work for me: #2366 (comment)

He asked me to open a new issue since his original issue had been resolved.

Thanks for the great library! I love working with Stencil and am excited to get my SSR working! Let me know if you need any other info from me 🙂

Metadata

Metadata

Assignees

No one assigned

    Labels

    ionitron: stale issueThis issue has not seen any activity for a long period of time

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions