Skip to content

Optimized async functional components fail to server-side render on initial render #12983

Open
@vetruvet

Description

@vetruvet

Version

2.7.14

Reproduction link

stackblitz.com

Steps to reproduce

Run main.js in the reproduction link

What is expected?

Each render in that reproduction would work

What is actually happening?

The first render of OptimizedAsyncFunctionalComponent fails, but subsequent ones succeed.


It appears that vue-server-renderer calls installSSRHelpers which adds _ssrNode and other SSR optimization helpers to Vue.prototype and Vue.FunctionalRenderContext.prototype. However, when rendering an async functional component, the built version of vue-server-renderer has its own definition of FunctionalRenderContext (appears to be bundled at build time along with things like createFunctionalComponent instead of importing from vue itself at runtime) which does not have the SSR helpers on it.

Setting optimizeSSR: false in vue-loader options seems to work as a bandaid solution since the optimization helpers are not used, but this seems like a bad idea for performance.
EDIT: also, changing it to a regular component (not functional) also works as a workaround

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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