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

Hydration warning mixes up client/server results #3690

Closed
alejandrovrojas opened this issue Jun 6, 2021 · 3 comments
Closed

Hydration warning mixes up client/server results #3690

alejandrovrojas opened this issue Jun 6, 2021 · 3 comments
Labels
bug: upstream Bug in a dependency of Vite feat: ssr

Comments

@alejandrovrojas
Copy link

Describe the bug

The client correctly warns when there's a hydration mismatch between the client and server, but the warning mixes up the results, showing the client state as server state and vice versa.

Reproduction

Defining a component's state that's dependent on client-side hydration, something like:

<template>
  <div>{{ value }}</div>
</template>

<script>
  export default {
    setup() {
      return { 
        value: import.meta.env.SSR ? "SSR" : "client"
      };
    },
  };
</script>

Will show the warning:

[Vue warn]: Hydration text content mismatch in <div>:
- Client: "SSR"
- Server: "client"

System Info

  System:
    OS: macOS 11.4
    CPU: (8) arm64 Apple M1
    Memory: 499.11 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.1.0 - /opt/homebrew/bin/node
    npm: 7.14.0 - /opt/homebrew/bin/npm
  Browsers:
    Chrome: 91.0.4472.77
    Firefox: 89.0
    Safari: 14.1.1
  npmPackages:
    @vitejs/plugin-vue: ^1.2.3 => 1.2.3 
    vite: ^2.3.6 => 2.3.6 

Used package manager: npm

@bluwy
Copy link
Member

bluwy commented Mar 11, 2022

Still happening in Vite 2.9.0-beta.0, but it looks like a bug in Vue perhaps?

https://github.com/vuejs/core/blob/0342fae8ad0e71866e9b9725a1f9c471db775c76/packages/runtime-core/src/hydration.ts#L365-L372

Or something with HMR.

@sapphi-red sapphi-red added bug: upstream Bug in a dependency of Vite and removed pending triage labels May 28, 2022
@bluwy
Copy link
Member

bluwy commented Jun 25, 2022

Closing as it's an upstream issue. Perhaps it's also fixed as the code has changed

https://github.com/vuejs/core/blob/25f7a16a6eccbfa8d857977dcf1f23fb36b830b5/packages/runtime-core/src/hydration.ts#L134-L141

@bluwy bluwy closed this as not planned Won't fix, can't repro, duplicate, stale Jun 25, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Jul 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug: upstream Bug in a dependency of Vite feat: ssr
Projects
None yet
Development

No branches or pull requests

4 participants