Comments (10)
@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.
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 ssrRef
s – 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.
Hi, I was curious about this bug so I tried to reproduce it. My experience:
- There's no
interval: 2000
but I commented out theinterval
line undergenerate:
. - 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 generatedno-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.
@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.
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.
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 inglobalRefs
:"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 befuncValue
"only SSR rendered"
– must berefValue
{v:{deep:t}}
andt
– these should beshallow
andnoChange
, except I think the injected value should be"server"
and"initValue"
respectively, so... maybe I'm in too deep here"result"
– this is theonServerPrefetch
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 shallow
– prefetchValue
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.
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.
@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.
@danielroe could you detail these rare instances so we can document them and update the docs accordingly?
from composition-api.
@Rigo-m I am referring to #44 (comment)
from composition-api.
Related Issues (20)
- fix: Can't pass object to template after update the version from 0.32.0 to 0.33.x HOT 4
- fix: Error: Unknown file extension: [...]node_modules/pathe/dist/index.cjs HOT 2
- help: Cannot call useContext() inside watch() callback HOT 4
- help: Failed to compile with 1 errors * @nuxtjs/composition-api in ./.nuxt/composition-api/meta.mjs HOT 2
- feat: A method to opt-out of automatic use of useMeta HOT 1
- help: Before mount, await useFetch HOT 13
- help: A circular reference error occurs when useFetch and useRouter are used together. HOT 1
- help: The object containing exported methods in the setup function is an empty object.
- help: How to set 'noindex' for SEO for a specific component? HOT 1
- help: Computed property based on an object prop HOT 1
- fix: useContext().error() with useAsync() causes hydration error HOT 1
- help: Cannot use import statement outside a module HOT 4
- fix: Module should export a function: @nuxtjs/composition-api HOT 5
- help: I can't use useHead in nuxt 2 HOT 1
- help: i get a error that show "[error] (node:19103) [DEP0148] DeprecationWarning: Use of deprecated folder mapping "./" in the "exports" field module resolution of the package at /home/apache/.jenkins/workspace/prod/node_modules/@nuxtjs/composition-api/package.json. Update this package.json to use a subpath pattern like "./*". "" when i run "npm i"
- fix: `redirectedFrom` not exists in `useRoute()`
- docs: How do I register middleware in script setup HOT 1
- help: I don't receive fresh data via useAsyncData when change params. HOT 1
- Extend package.json to be compatible with moduleResolution: bundler
- fix: watch and useRoute() not working HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from composition-api.