Skip to content

SSR fails on async components #402

@jakub300

Description

@jakub300

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

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