vuejs / vue

This is the repo for Vue 2. For Vue 3, go to https://github.com/vuejs/core
http://v2.vuejs.org
MIT License
208.06k stars 33.69k forks source link

SSR error during $style injection on cached components #9010

Open henriqemalheiros opened 6 years ago

henriqemalheiros commented 6 years ago

Version

2.5.17

Reproduction link

https://github.com/henriqemalheiros/vue-ssr-cached-component-css-modules

Steps to reproduce

The error is also reproducible in development mode with yarn run ssr:serve.

What is expected?

The app should render properly, as it rendered before refreshing the page.

What is actually happening?

error during render : /
TypeError: Cannot set property '$style' of undefined
    at CachedComponent_injectStyles (src/components/CachedComponent.vue:8:0)
    at hook (node_modules/vue-loader/lib/runtime/componentNormalizer.js:53:0)
    at c:\[...]\vue-ssr-cached-component-css-modules\node_modules\vue-server-renderer\build.js:7467:15
    at c:\[...]\vue-ssr-cached-component-css-modules\node_modules\vue-server-renderer\build.js:2487:40
    at c:\[...]\vue-ssr-cached-component-css-modules\node_modules\vue-server-renderer\build.js:7465:11
    at c:\[...]\vue-ssr-cached-component-css-modules\node_modules\vue-server-renderer\build.js:2487:40
    at renderComponent (c:\[...]\vue-ssr-cached-component-css-modules\node_modules\vue-server-renderer\build.js:7463:7)
    at RenderContext.renderNode (c:\[...]\vue-ssr-cached-component-css-modules\node_modules\vue-server-renderer\build.js:7418:5)
    at RenderContext.next (c:\[...]\vue-ssr-cached-component-css-modules\node_modules\vue-server-renderer\build.js:2436:14)
    at cachedWrite (c:\[...]\vue-ssr-cached-component-css-modules\node_modules\vue-server-renderer\build.js:2295:9)

If you remove the serverCacheKey from the cached component and try again, the app renders properly.

Originally I thought this was a Nuxt related issue (nuxt/nuxt.js#3868). I then forgot about the issue, since I ditched component caching, but now I was able to find the time to reproduce it with plain Vue.

LinusBorg commented 6 years ago

Thanks for reporting this, we will have a look as soon as we can.

iztsv commented 5 years ago

@LinusBorg do you have any news about the issue?

anzolo commented 5 years ago

I have same issue :(

andreynazarov3 commented 5 years ago

any news?

AntonMoskalchenko commented 4 years ago

It is very sad news that using "nuxt": "2.11.0" I still have the same bug

v-angolenko commented 3 years ago

any news?

radislaw commented 3 years ago

I faced the same problem

serzz1990 commented 3 years ago

any news?

devseregik commented 3 years ago

why is the problem still not solved?

alexander-rodin commented 2 years ago

any news?

imzedi commented 3 months ago

any news?

mefcorvi commented 3 months ago

Actually, I don't think this is going to be fixed because both Nuxt2 and Vue2 are EOL already. As far as I know, there is no such thing as component-level cache in Nuxt3.