Vue-apollo: SSR fails on async components

Created on 29 Sep 2018  路  4Comments  路  Source: vuejs/vue-apollo

Steps to reproduce:

  1. Create project using vue cli with vue router, ssr and apollo.
  2. In Home.vue replace HelloWorld component in components with HelloWorld: () => import('@/components/HelloWorld.vue'),
  3. Error similar to the one below will be shown in terminal after ssr attempt (manual page enter/refresh):
(node:2248) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'props' of undefined
    at normalizeProps (E:\Projects\Learning\vue-test-1\node_modules\vue\dist\vue.runtime.common.js:1354:23)
    at Object.mergeOptions (E:\Projects\Learning\vue-test-1\node_modules\vue\dist\vue.runtime.common.js:1456:3)
    at exports.getMergedDefinition (E:\Projects\Learning\vue-test-1\node_modules\vue-apollo\lib\utils.js:14:27)
    at Promise.then.component (E:\Projects\Learning\vue-test-1\node_modules\vue-apollo\ssr\utils.js:188:19)

The origin of the stack trace:

  • /ssr/index.js: vm.$createElement is called with component name and passes it to resolveComponent
  • /ssr/utils.js: resolveComponent calls resolveAsset that returns function (it is our function that returns import)
  • that function is later passed to getMergedDefinition that passes it to Vue's mergeOptions
  • mereOptions reads .options from it, at this point child is undefined because options exists only on real components
  • mergeOptions is calling normalizeProps that attempts to read .props

Most helpful comment

All 4 comments

Any idea how to solve this issue? I'd like to publish a working solution for the apollo module on Nuxt. This issue happens after beta.19 release

Has this been fixed?

See #469

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mathe42 picture mathe42  路  4Comments

dohomi picture dohomi  路  5Comments

dsbert picture dsbert  路  4Comments

jsrkstr picture jsrkstr  路  3Comments

apertureless picture apertureless  路  4Comments