ui icon indicating copy to clipboard operation
ui copied to clipboard

Hydration attribute mismatch after update Nuxt to v3.9.0

Open ivan-mihalic opened this issue 2 years ago • 47 comments

Environment

  • Operating System: Linux
  • Node Version: v18.18.0
  • Nuxt Version: 3.9.0
  • CLI Version: 3.10.0
  • Nitro Version: 2.8.1
  • Package Manager: [email protected]
  • Builder: -
  • User Config: devtools, modules, ui
  • Runtime Modules: @nuxt/[email protected]
  • Build Modules: -

Version

v2.11.1

Reproduction

https://stackblitz.com/edit/nuxt-starter-5tmfpt?file=components%2FUserForm.vue

Description

Hi guys, I updated Nuxt to version 3.9.0 and I am getting Hydration attribute mismatch for example on USelectMenu or UDropdown viz screenshot. I think it is a bug and it is now showing after improve ssr hydration mismatch checks in Vue 3.4.

CleanShot 2023-12-29 at 17 38 06@2x

Additional context

No response

Logs

No response

ivan-mihalic avatar Dec 29 '23 16:12 ivan-mihalic

I do have the same issue

MickL avatar Dec 29 '23 19:12 MickL

I have the same issue

hoanghadu avatar Dec 30 '23 23:12 hoanghadu

Also occurring with UCheckbox, here's a minimal reproduction (app.vue):

<template>
  <UCheckbox v-model="state" label="Test checkbox" />
</template>

<script setup lang="ts">
const state = ref(true)
</script>

Notably does not occur when the ref is false.

Testing against 2.11.1 and 7151b7b97d42f389506521044ebaffa8a299e7fb with [email protected] both yield the same result. image

rosellle avatar Jan 02 '24 02:01 rosellle

getting same things now after the update

pixelpaulaus avatar Jan 02 '24 05:01 pixelpaulaus

I also got plenty of hydration mismatch after upgrade.

tabuz avatar Jan 02 '24 10:01 tabuz

same bug but without info after upgrade to 3.9.0 I tried with --no-force and --force and i have the same issue

Screenshot 2024-01-02 at 15 09 50

fishDev94 avatar Jan 02 '24 14:01 fishDev94

Same here with ui-pro/landing template

ahoiroman avatar Jan 02 '24 14:01 ahoiroman

I think this is due to latest vue 3.4, we have to override all of Headless UI generated ids with the future useId composable from Nuxt: https://github.com/nuxt/nuxt/pull/23368 but it hasn't been released yet.

In the meantime, can you try to set the resolution to vue to 3.3.13?

benjamincanac avatar Jan 02 '24 15:01 benjamincanac

I think this is due to latest vue 3.4, we have to override all of Headless UI generated ids with the future useId composable from Nuxt: nuxt/nuxt#23368 but it hasn't been released yet.

In the meantime, can you try to set the resolution to vue to 3.3.13?

3.3.13 fixed it for me for now, thanks!

yoricktran avatar Jan 04 '24 00:01 yoricktran

Nuxt3.9.1 still has this problem and 3.3.13 can solve it

whcxxb avatar Jan 08 '24 06:01 whcxxb

Sorry for anoob question, but how did you achieved to pin [email protected]?

My package.json looks like below

{
  "private": true,
  "scripts": {
    "build": "nuxt build",
    "dev": "nuxt dev",
    "generate": "nuxt generate",
    "preview": "nuxt preview",
    "postinstall": "nuxt prepare"
  },
  "dependencies": {
    "@nuxt/ui": "^2.11.0",
    "@nuxtjs/google-fonts": "^3.1.0",
    "@pinia/nuxt": "^0.5.1",
    "consola": "^3.2.3",
    "nuxt-proxy": "^0.4.1",
    "pinia": "^2.1.7",
    "sass": "^1.69.5",
    "vue": "^3.3.9",
    "zod": "^3.22.4"
  },
  "devDependencies": {
    "@iconify/vue": "^4.1.1",
    "@nuxt/devtools": "^1.0.3",
    "@nuxtjs/i18n": "^8.0.0-rc.5",
    "@vueuse/core": "^10.6.1",
    "@vueuse/nuxt": "^10.6.1",
    "nuxt": "^3.9.0",
    "prettier": "^3.1.0",
    "prettier-plugin-tailwindcss": "^0.5.7"
  }
}

tabuz avatar Jan 08 '24 10:01 tabuz

You need to set it in resolutions:

{
  "private": true,
  "scripts": {
    "build": "nuxt build",
    "dev": "nuxt dev",
    "generate": "nuxt generate",
    "preview": "nuxt preview",
    "postinstall": "nuxt prepare"
  },
  "dependencies": {
    "@nuxt/ui": "^2.11.0",
    "@nuxtjs/google-fonts": "^3.1.0",
    "@pinia/nuxt": "^0.5.1",
    "consola": "^3.2.3",
    "nuxt-proxy": "^0.4.1",
    "pinia": "^2.1.7",
    "sass": "^1.69.5",
    "vue": "^3.3.9",
    "zod": "^3.22.4"
  },
  "devDependencies": {
    "@iconify/vue": "^4.1.1",
    "@nuxt/devtools": "^1.0.3",
    "@nuxtjs/i18n": "^8.0.0-rc.5",
    "@vueuse/core": "^10.6.1",
    "@vueuse/nuxt": "^10.6.1",
    "nuxt": "^3.9.0",
    "prettier": "^3.1.0",
    "prettier-plugin-tailwindcss": "^0.5.7"
  },
  "resolutions": {
    "vue": "3.3.13"
  }
}

benjamincanac avatar Jan 08 '24 10:01 benjamincanac

@benjamincanac Thank you for quick reply. I've tried what you suggested and while executing npm list vue is shows as [email protected] deduped everywhere and app itself still throws hydration mismatch.

npm package.json docs doesnt mention usage of keyword resolutions. Should I use this package https://www.npmjs.com/package/npm-force-resolutions ?

tabuz avatar Jan 08 '24 10:01 tabuz

Oh sorry, this is for yarn and pnpm. It seems you can use overrides with npm since 8.3.0.

benjamincanac avatar Jan 08 '24 10:01 benjamincanac

i have the same issue with UTable - hydration mistmaches - warning on UCheckbox inside table component really dont want to downgrade versions(( any info when we can get update?

lammerfalcon avatar Jan 10 '24 12:01 lammerfalcon

This seems related as well. See the following reproduction:

https://stackblitz.com/edit/nuxt-starter-t3xebe?file=components%2FAttributeTest.vue

I have a form with a dynamic action attribute. I even understand the hydration attr mismatch but why is the value wrong on initial load. It should have loaded with "something" and then changed to the clientside date/time. It can change based on the button click. This was unexpected for us.

dolbex avatar Jan 10 '24 13:01 dolbex

I'm facing the same issue

RomanSkrypnik avatar Jan 10 '24 17:01 RomanSkrypnik

i do have the same issue -\^-^/-

sync42johnny avatar Jan 10 '24 17:01 sync42johnny

Ditto here.. causing all sorts of mismatches with a whole bunch of deps (headless, radix, etc etc). Think the best fix is upstream in vue?

I'm using Bun, which supports both the overrides and resolutions syntax. So the temporary solution for me is in package.json:

"overrides": { "vue": "3.3.13" },

jontybrook avatar Jan 10 '24 20:01 jontybrook

Nuxt3.9.1仍然有这个问题,3.3.13可以解决

所以是要降低版本来解决这个问题吗

jiangdotgs avatar Jan 11 '24 06:01 jiangdotgs