Skip to content
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 computed() memory leak, because the isInSSRComponentSetup variable is set to false on the server #15095

Closed
mrauhu opened this issue Oct 5, 2022 · 4 comments

Comments

@mrauhu
Copy link
Contributor

mrauhu commented Oct 5, 2022

Environment

  • Operating System: Linux
  • Node Version: v16.15.0
  • Nuxt Version: 3.0.0-rc.11
  • Nitro Version: 0.5.4
  • Package Manager: npm@8.5.5
  • Builder: vite
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

<script setup lang="ts">
import { computed } from 'vue';

// ...

debugger;
const result = computed(() => processor(props.input));
</script>

Then run with debugger, and step into computed() function, you will see the isInSSRComponentSetup variable is set to false on the server.

image

Describe the bug

Nuxt 3 SSR is not setting the isInSSRComponentSetup variable to true on the server, that used in the computed() function, see:

Temporary fix

<script setup lang="ts">
// Importing original `computed()` function with three arguments, to use latest, the `isSSR`
// eslint-disable-next-line vue/prefer-import-from-vue
import { computed } from '@vue/reactivity';

// ...

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const result = computed(() => processor(props.input), undefined, process.server);
</script>

Additional context

Memory consumption

Production build of an application, 60 requests per second, 10 minutes of load (36 000 requests).

Before fixes

image

After fixes

Includes fix from #15093.

image

Memory difference

Flame graph

image_2022-10-04_22-44-30

Table

image_2022-10-04_22-42-43

Logs

No response

@danielroe
Copy link
Member

let's track in #15093 as that's the presenting cause

@danielroe danielroe closed this as not planned Won't fix, can't repro, duplicate, stale Oct 5, 2022
@mrauhu
Copy link
Contributor Author

mrauhu commented Oct 25, 2022

@danielroe would you reopen this issue after #15093 is closed?

@danielroe
Copy link
Member

I believe my comment is relevant here as well: #15093

If you are still experiencing an issue would you provide a reproduction please? 🙏

@mrauhu
Copy link
Contributor Author

mrauhu commented Oct 25, 2022

If you are still experiencing an issue would you provide a reproduction please?

I will check current Nuxt behavior of calling the computed() function on the server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants