question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Nested async components passed as slots are not rendered in SSR

See original GitHub issue

Version

2.6.10

Reproduction link

https://codesandbox.io/s/vue-ssr-nested-async-components-repro-script-ozze7

Steps to reproduce

When the codesandbox starts up, it should run the npm start script. If it doesn’t, open a bash terminal and run npm start to see the HTML generated from SSR. You can also take a look at the components in the src folder to see how they are configured.

What is expected?

Expected the HTML for the nested async component (called “SomeComponent”) to be rendered during SSR:

<div data-server-rendered="true">
  <div class="Grid">
    <div class="Grid__left">Left
      <div class="SomeComponent">Somecomponent with value: first</div>
    </div>
    <div class="Grid__right">Right
      <div class="SomeComponent">Somecomponent with value: second</div>
    </div>
  </div>
</div>

What is actually happening?

The HTML for the nested async component (called “SomeComponent”) is not rendered during SSR. Only the HTML for the outer async component (called “Grid” ) is rendered:

<div data-server-rendered="true">
  <div class="Grid">
    <div class="Grid__left">Left
    </div>
    <div class="Grid__right">Right
    </div>
  </div>
</div>

I have an App that is composed of many async components. Some of these components have named slots. I was trying to build a render function that will accept a config object to render these components in various setups (for example, an async component set to a named slot of another async component). I noticed that if I nest async components within another, the HTML for the async component does not render during SSR. The codesandbox is simplified scenario of this

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:7
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
pi0commented, Mar 16, 2021

Here is a minimalistic reproduction: https://replit.com/@pi0/vuejsvue10391

Issue seems caused by https://github.com/vuejs/vue/commit/781c70514e01bc402828946805bfad7437c7175e. For some reason, for async components isComment is true. Reverting L65 fixes but I guess have to investigate why isComment is true for proper fix. we should check with isAsyncPlaceholder

Update: https://github.com/vuejs/vue/pull/11963

2reactions
trip-somerscommented, Apr 1, 2020

I have a similar problem that appears to be some kind of a race condition. I’m not sure if it should be a new issue, so I’ll start here and describe it.

My app is a multi-page app with a main app.js file that essentially configures the separate pages as async components, so that we don’t have to pack hundreds of components into a single app.js file. The result is a pattern counter to what @posva suggested. For example, someone would visit /shipment/12345/edit and the main js file would load normally with the Shipment component loading asynchronously.

The problem I have is that the Shipment component only renders sometimes. It always mounts, as evidenced by ‘Shipment component mounted’ console logs. When it doesn’t render, the DOM where it should be is simply blank. Rendering seems to be more reliable when ‘Disable Cache’ is checked in dev tools. This makes it seem like a race condition, but I can only imagine what that condition could be.

EDIT: I am not using SSR, so this would appear to be similar but unrelated. If this comment is off-topic as a result or not constructive, you won’t hurt my feelings by removing/hiding it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to setup render function to render dynamically imported ...
I have an App that is composed of many dynamically imported components. Some of these components have named slots.
Read more >
How to SSR nested components or slotted content with ...
I am trying to add Vue.js components to a Ruby-on-Rails app with SSR support by using Hypernova and vueonrails helpers. I am able...
Read more >
Advanced usage - Vuelidate
When using useVuelidate , Vuelidate will collect all validation $errors and $silentErrors from all nested components. No need to pass any props or...
Read more >
Blog - Layouts RFC - Next.js
Nested Layouts: Build complex applications with nested routes. Designed for Server Components: Optimized for subtree navigation.
Read more >
A deep analysis into isomorphic, autonomous cross ... - ITNEXT
SSR Shadow DOM / Approach 2: hiding the slot. ... Nested components have to be slotted (as described above) and are therefore NOT...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found