New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nuxt 3: SSR memory leak in useHead()
with computed getter on the server
#15093
Comments
Hey @mrauhu, thanks for the detailed audit. Worth noting that the version of @vueuse/head in Nuxt RC 11 (0.7.12) does not officially support computed getter syntax. It was introduced in https://github.com/vueuse/head/releases/tag/v0.8.0. As there's no reproduction, would it be possible for you to test out https://github.com/harlan-zw/nuxt-hedge and see if it has the same issue? This uses the latest @vueuse/head, which I'm working to get into the core (nuxt/framework#8000). Also, could you share your |
Hi @harlan-zw.
Tested
Basically it's just converter from a flat object of metatags to // Simplified version
export function getMeta(meta: Record<string, string>) {
const result = {
meta: [],
} as MetaObject;
for (const [key, value] of Object.entries(meta)) {
result.meta.push({
name: key,
key: key,
content: value,
});
}
return result;
} Computed getter in
|
Thank you @mrauhu I have some ideas on how to improve this, but it includes some risky changes around reactivity so it may not be available until @vueuse/head v1. Will give you a ping when there's something to test |
I have a question off topic. What is the name of the program/application you use to track of memory? |
@antlionguard Datadog APM with Continuous profiler. |
Hey @mrauhu I have worked on the performance improvements, they are available in nuxt-hedge 0.5.0. The client-side performance should be improved, the server performance should be a bit more stable but hard to say if it's solved the memory leak issue as I don't know the full scope of how the ssrContext is used. |
Potential fix is also available in |
The issue here was not actually (IIRC) the use of I believe this is resolved as computed is no longer being called by Let me know if not and I'll happily reopen. |
Environment
Linux
v16.15.0
3.0.0-rc.11
0.5.4
npm@8.5.5
vite
-
-
-
Reproduction
Describe the bug
Using a computed getter (
() => ...)
) as an argument of thegetHead()
results to memory leak on the server.See also: #15095.
Temporary fix
Additional context
Memory consumption
Production build of an application, 60 requests per second, 10 minutes of load (36 000 requests).
Before fix
After fix
Memory difference
Flame graph
Table
Logs
No response
The text was updated successfully, but these errors were encountered: