nitro icon indicating copy to clipboard operation
nitro copied to clipboard

[vite] Very high memory usage when building tanstack start

Open xKesvaL opened this issue 3 months ago • 13 comments

Environment

  • Vite nitro (nightly) 3.0.0-20250925 to be precise Vite config:
const config = defineConfig({
  plugins: [
    // this is the plugin that enables path aliases
    viteTsConfigPaths({
      projects: ["./tsconfig.json"],
    }),
    tailwindcss(),
    tanstackStart(),
    nitro({
      config: {
        preset: "bun",
      },
    }),
    viteReact(),
  ],
});

Reproduction

I've tried reproducing the issue using the create-start-app with almost all addons to make the app bigger : https://github.com/xKesvaL/nitro-v3-high-memory

I do have a slightly bigger repo to test this on (see below), but it's private. Any maintainer is welcome to message me and I will happily give it to them.

Describe the bug

I am finding integrating the nitro v3 vite plugin with the new tanstack start RC is yielding way higher memory usage.

Image Image

The two graphs are memory usage on my VPS while building latest start (132.7) + nitro v3 vite plugin (first) VS building beta start, the second one. As mentioned before, this is the private repo.

The build on the left did not manage to finish, as it ran out of memory.

I don't know where this comes from, but will be happy to help if I can

Here's the public repo I made with create-start-app, i've highlighted in red the moment nitro kicks in and memory usage ramps up crazily in 3-5 seconds. In green is vite. It's not as bad as on my VPS, but also not as big of a project.

Image

Additional context

No response

Logs


xKesvaL avatar Sep 25 '25 18:09 xKesvaL

Can you help making a minimal nitro reproduction without tanstack-start plugin?

cc @schiller-manuel

pi0 avatar Sep 25 '25 18:09 pi0

Not sure at all how nitro and tanstack start work together in the background, so I'll leave that to Manuel, sorry!

xKesvaL avatar Sep 25 '25 19:09 xKesvaL

No worries. I will also try to investigate later but might be much easier to find root cause with minimal reproduction. We will fix it 💯

pi0 avatar Sep 25 '25 19:09 pi0

@xKesvaL can you share that private repo with me please?

schiller-manuel avatar Oct 23 '25 22:10 schiller-manuel

Sorry for the delay, I just invited you as a collaborator. The branch you're looking for is nitro-v3-high-memory-again. After installing packages, you can just cd apps/app and run the build script there. It shouldn't cause any problem that you don't have anything set up.

I found that when trying to build the app on my VPS, I even hit a javascript out of memory error. On my PC, I find that vite gets my RAM up around ~0.5Gb, and as soon as the "Building nitro" appears in terminal, it will heavily grow to 1.5 to 2Gb

xKesvaL avatar Oct 27 '25 17:10 xKesvaL