Skip to content

Suspense / ErrorBoundary content rendered twice when hydrating with render #4439

@PhilippMi

Description

@PhilippMi
  • Check if updating to the latest Preact version resolves the issue

Describe the bug

We use ErrorBoundary and lazy from preact-iso for code-splitting our application but still being able to server-side render them in advance. With the upgrade to >10.19.0, we noticed that all our lazy components are rendered twice when first server-side rendered.

One important thing to note is that we use render instead of hydrate for hydrating our server-side rendered HTML because the server-side markup differs from what we render on the client. The bug does not appear when using hydrate. But changing that behaviour in our application would take an immense effort.

Switching from ErrorBoundary to Suspense did not solve the bug.

To Reproduce

  1. Go to https://codepen.io/phmitterer/pen/eYwYrpB
  2. Server-side rendering is simulated and "Hello, World!" is rendered
  3. After 1 second, client-side hydration kicks in and renders a second "Hello, World!"

Here is the same bug with Suspense instead of ErrorBoundary: https://codepen.io/phmitterer/pen/oNrNOVJ

Expected behavior

"Hello, World!" is only rendered once.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions