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

Vite and services refuse to work together #1569

Closed
Lempac opened this issue Nov 3, 2024 · 9 comments
Closed

Vite and services refuse to work together #1569

Lempac opened this issue Nov 3, 2024 · 9 comments
Labels
question Further information is requested

Comments

@Lempac
Copy link

Lempac commented Nov 3, 2024

(The only reason i asking this as question is i dont know if this is a bug)

When updating to devenv 1.3.1, for whatever reason when running vite dev in devenv environment while a services is included in config like mysql or mailpit, vite starts using 30-40% cpu and eat ram until crashes from javascript out of memory.

Otherwise it works fine when no services are included(services.X.enable = false;) and all processes are commend out with devenv up.

Even funnier when i do:

processes = {
   vite.exec = "npm run dev";
};

It start doing the same thing as if service wound be included(which i mean it is, it self as service).

Here are some devenv files.

Im just confused if im doing something wrong?

@Lempac Lempac added the question Further information is requested label Nov 3, 2024
@sandydoo
Copy link
Member

sandydoo commented Nov 3, 2024

I doubt this is related to devenv.

The only way to figure out what's going on is by finding out what vite is doing. vite dev supports a --debug flag that might include interesting info and a --profile flag, which should let you attach a debugger, like chrome's inspector.

@linusfri
Copy link

linusfri commented Nov 5, 2024

We have exactly the same problem as you. We tried updating every input in the lock file separately and as soon as we update the devenv input we get memory leaks until node crashes.

We have tried running "vite dev --debug" and this doesn't show anything out of the ordinary. Also, if we let the node processes reach a certain level of memory use, devenv refuses to exit when doing a "Ctrl+C" in the active devenv terminal window.

Here is a rather boring video which illustrates the behavior:
https://github.com/user-attachments/assets/7ebce612-9b95-4fa7-ac7d-c7420f15c5c6

@Lempac
Copy link
Author

Lempac commented Nov 5, 2024

I will be testing more and try running it again, but the last time I ran a vite profile(delete the result, silly me) I saw something like "_read" was taking a lot of performance.

@Lempac
Copy link
Author

Lempac commented Nov 5, 2024

Okey so here are some profiles.
Before updating devenv:
vite-profile-with-old-devenv.cpuprofile
And after updating devenv, but without any processes and services:
vite-profile-no-processes-or-service.cpuprofile
And after updating devenv with processes:
vite-profile-with-processes.cpuprofile
And after trying to switch to nix unstable:
vite-profile-with-nix-unstable.cpuprofile

The main differences are _read eating performance and the ones with processes and updated devenv continuously doing something(while other stop doing anything after 400ms).

This is what i used to test this:

{
  languages.javascript.enable = true;
  languages.javascript.bun.enable = true;

  processes = {
    vite.exec = "bun run dev"; #simply commenting this out for no processes.
  };
}

This is the vite version(it doesnt change between locks):
vite/5.4.10 linux-x64 node-v20.11.1
Nix unstable version:
vite/5.4.10 linux-x64 node-v20.18.0

@sandydoo
Copy link
Member

sandydoo commented Nov 5, 2024

I attached the chrome inspector to the node process and stepped through a few loops.

The vite file watcher is getting caught in a symlink loop in .devenv/profile/include/ncurses/ncurses. There are two symlinks in there, ncurses and ncursesw, pointing to themselves. I don't know the reasoning behind this, but this would be an upstream nixpkgs issue.

The current workaround would be to configure vite to not watch .devenv.

@sandydoo
Copy link
Member

sandydoo commented Nov 5, 2024

The reason this is showing up after updating devenv is because we added ncurses as a dependency if the process-compose TUI is enabled, which it is by default.

@sandydoo
Copy link
Member

sandydoo commented Nov 5, 2024

I've reverted the ncurses PR until we can figure out a compromise.

I didn't find a way to tell vite not to watch .devenv. I tried setting server.watch to null, ignored: [ ".devenv/**" ], and followSymlinks: false. Still loops.

@sandydoo
Copy link
Member

sandydoo commented Nov 5, 2024

Bumped vite to 6.0 beta and the chokidar options now do something.

export default {
  server: {
    watch: {
      ignored: [ "**/.devenv/**" ],
      // This would also work
      // followSymlinks: true,
    },
  },
}

@sandydoo
Copy link
Member

sandydoo commented Nov 7, 2024

Fixed by #1576. Please run devenv update devenv or nix flake update devenv to get the latest modules.

@sandydoo sandydoo closed this as completed Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants