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.

serverPrefetch doesn't work as expected

See original GitHub issue

Version

2.6.10

Steps to reproduce

Suppose we have a component:

export default {
    data(){
        return { foo: null}
    }
    async serverPrefetch(){
        this.foo = 'serverPrefetch'
    },
    created(){
        this.foo = 'created'
    },
}

foo is initially null, then created() updates it to created and this reflects in the html interpolitatiion, but when serverPrefetch() updates this.foo it is not reflected on the rendered html, despite being called afterwards.

What is expected?

serverPrefetch() should reflect rendered and updated data variables when rendered on SSR

What is actually happening?

serverPrefetch() doesn’t update the rendered view with new data after being called

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:36 (17 by maintainers)

github_iconTop GitHub Comments

3reactions
Akryumcommented, Apr 27, 2019

To conclude: your steps 2 and 4 in your diagram are not technically possible.

3reactions
yyx990803commented, Apr 26, 2019

@DominusVilicus the code you originally posted is working as expected (per test case). By design, a component’s serverPrefetch should only affect data of its own (or child components via passed props). The only case that it “doesn’t work” is that when a component’s serverPrefetch is mutating state that doesn’t belong to itself.

Read more comments on GitHub >

github_iconTop Results From Across the Web

VueJS sever-side-rendering: computed property not seeing ...
So at (4) I tried to recreate the hard-code fetchPage by having data ready before creating the component. However I didn't expect the...
Read more >
Server-Side Rendering (SSR) - Vue.js
This works as expected in a pure client-side Vue application, since the modules in our application are initialized fresh for each browser page...
Read more >
Need help regarding server prefetch - Vue Storefront
Hello Everyone. i have created module to list data and create detail page for that list now i have used serverPrefetch in detail...
Read more >
SQL Server Prefetch and Query Performance - Simple Talk
The following script took almost 6 mins to run in my notebook. ... I think the results will be similar, I don't expect...
Read more >
Server-side rendering with Vue InstantSearch - Algolia
You can then start the development server by running npm run ssr:serve . ... in your browser, you won't see the search results...
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