Giter Club home page Giter Club logo

Comments (10)

danielroe avatar danielroe commented on May 30, 2024 3

@eostrom I appreciate you diving into this. This should now only be an issue if ssrRef is used outside of setup context.

from composition-api.

eostrom avatar eostrom commented on May 30, 2024 1

If a missing ssrRef from onServerPrefetch is the symptom, then git bisect suggests it was fixed in commit 61a3b55 (Dec. 12), "ensure ssrRef doesn't share state across requests when used in setup()." That commit is definitely about ssrRefs – whether it solved the async problem, or just serverPrefetches, or just shuffled around where the bug is, I don't know.

Both of these results (and all the others I got while running git bisect) are with interval commented out.

Before:

window.__NUXT__ = {
  layout: 'default',
  data: [{}],
  fetch: [],
  error: null,
  serverRendered: !0,
  routePath: '/ssr-ref',
  config: { globalInject: 'injected' },
  ssrRefs: {
    'az7O9pBYRKHNFepJZ7cA1Q==': 1,
    'ol3L31Q278V6UERkKfCPoQ==': 'runs SSR or client-side',
    'l/lQeqSfcCkg14ujE8MvkA==': { v: { deep: 'server' } },
    'CfZaYpEA7G1eCb7DcuLcKA==': 'only SSR rendered',
    'taekfimpnaxhAVnvsFWIbQ==': 0,
  },
}

After:

window.__NUXT__ = function(e) {
  return {
    layout: 'default',
    data: [{}],
    fetch: [],
    error: null,
    serverRendered: !0,
    routePath: '/ssr-ref',
    config: { globalInject: 'injected' },
    globalRefs: { 'az7O9pBYRKHNFepJZ7cA1Q==': 1, 'taekfimpnaxhAVnvsFWIbQ==': 0 },
    ssrRefs: {
      'ol3L31Q278V6UERkKfCPoQ==': 'runs SSR or client-side',
      'l/lQeqSfcCkg14ujE8MvkA==': { v: { deep: e } },
      'CfZaYpEA7G1eCb7DcuLcKA==': 'only SSR rendered',
      'AwWsPnLHZSNcjcLAqrKvAQ==': e,
      'coipqoB5y7ONatlBjVGnXw==': 'result',
    },
  }
}('server')

I also bisected based on a different criterion and found a different, earlier inflection point: d2b8af1 (June 19), "test: upgrade testcafe and increase export delay."

Before that commit, with interval disabled and the onServerPrefetch delay set to 10 seconds, each page generated takes, oh, 1-5 seconds – suggesting that page generation is kind of slow, but is not waiting for the prefetch to complete.

After the commit – which raises the (disabled!) interval from 2 to 3 seconds, and also makes other changes – most pages are much faster (because, no interval), but ssr-refs takes about ten seconds, suggesting that page generation is waiting for the prefetch to complete.

I don't know whether this means anything.

from composition-api.

eostrom avatar eostrom commented on May 30, 2024

Hi, I was curious about this bug so I tried to reproduce it. My experience:

  • There's no interval: 2000 but I commented out the interval line under generate:.
  • I wasn't sure what to inspect in ./dist/ssr-ref/index.html, but there do appear to be values for all the fields in the output.
  • The test "Shows SSR data when an ssrRef is defined outside setup" fails because 'async-prefetched async' is not found on the /no-setup page.
  • Curiously, when I run yarn nuxt generate -c test/fixture/nuxt.config.js and manually inspect the generated no-setup/index.html, 'async-prefetched async' is present.

I'm not sure I can get anywhere on fixing this, but is that failing test the thing that needs to be fixed?

from composition-api.

danielroe avatar danielroe commented on May 30, 2024

@eostrom I appreciate your looking into this! The issue seems to be not that the data isn't in the generated HTML, but that it isn't in nuxtState. Possibly using a vue-renderer hook might allow us to solve this, e.g. nuxt/nuxt#8852 (comment) and nuxt/nuxt#8620 (comment).

from composition-api.

Rigo-m avatar Rigo-m commented on May 30, 2024

Will you plan to fix this to correctly retrofit this functionality in a nuxt 2 project or should we avoid this functionality altogether? I'm planning to introduce @nuxtjs/composition-api in a project that will go live in june, but I'm not sure because of this caveat. (It's not feasible to generate a 4-5k pages website with an interval between pages)

from composition-api.

eostrom avatar eostrom commented on May 30, 2024

Ah! So, looking at the inline JS with and without interval, I see:

  • Different minimized parameter names for the __NUXT__ function – probably not important.
  • Without interval, there's an extra entry in globalRefs: "taekfimpnaxhAVnvsFWIbQ==":0.

I... don't really know what I'm looking at. But with or without interval, I see five entries in ssrRef. Their values are:

  • "runs SSR or client-side" – this must be funcValue
  • "only SSR rendered" – must be refValue
  • {v:{deep:t}} and t – these should be shallow and noChange, except I think the injected value should be "server" and "initValue" respectively, so... maybe I'm in too deep here
  • "result" – this is the onServerPrefetch one that the bug report seems to be talking about, but it's not missing

Thinking it might be a race condition, I raised the fetcher delay in ssr-ref.vue to 5000. The build appeared to wait five seconds for /ssr-ref to complete, and the output still had "result" in it. Also worked when I raised it to 50 seconds.

I tried rolling back this repo to 0.8.0 (the first minor version I found with an interval to comment out), and in that version the only ssrRefs generated were refValue, funcValue, and shallowprefetchValue and (surprisingly) noChange are missing.

Seems possible this bug got fixed by Nuxt at some point? But nuxt/nuxt.js#8852 (comment) was reported 17 days ago on a very recent version of Nuxt, so I don't know.

This is not quite as thorough as I would like, but I have to leave off and I'd rather share it than forget about it, so I'm posting what I have so far.

from composition-api.

liqueflies avatar liqueflies commented on May 30, 2024

Hi @danielroe, this issue is present only when using nuxt-cmposition-api fetch methods or also with nuxt asyncData and fetch old methods?

from composition-api.

danielroe avatar danielroe commented on May 30, 2024

@liqueflies This should only be present in rare circumstances with this library and not at all if using built-in Nuxt methods.

from composition-api.

Rigo-m avatar Rigo-m commented on May 30, 2024

@danielroe could you detail these rare instances so we can document them and update the docs accordingly?

from composition-api.

danielroe avatar danielroe commented on May 30, 2024

@Rigo-m I am referring to #44 (comment)

from composition-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.