Hello,
I’ve recently run into a particularly weird issue, I was working on a standard Astro v7 project when I noticed that starting the development server with resulted in a consistent, 20s+ launch time. I tried both bun and node but both had the same issue. Doing a build and then preview worked in about 4s.
I decided to dig deeper and managed to trace the issue to the function vite.createServer, specifically down to configureServer hooks, but that wasn’t particularly helpful. I ignored the issue and ran development via build and preview for some time until I decided to work on resolving it by initializing multiple vite projects (nextjs, svelte, astro) both with nodejs and bun, to my surprise there were no issues on any of them.
I was progressively tracing each one of the specific changes my project had compared to the base Astro project but nothing changed the result, until my storage filled and I ran nh clean all. After that, I started the dev server for my project (I was using a shell provided by nix develop at the time, which didn’t trigger direnv as I had only configured the fish direnv hook but not the bash one) and it launched in 4s. I then decided to start fish, which in turn loaded direnv, making the launch time 20s+ again. I went back to the nix develop provided shell and tried running it from there, only to see 20s+ start time again.
After a large amount of trying things, I managed to reduce the issue to:
- Seems to happen only with Astro, independent of runtime
- Clearing gcroots and then running the dev server via
nix developornix-shellboth work - The moment a direnv provided shell loads (and installs bun / node), the start time turns 20s+
- The issue is project dependent, meaning that loading a direnv provided shell corrupts only that specific project
- A corrupted project will affect any bun / node installation that is added to the path, this means that even if I source a external flake via
--impure, the provided runtimes will still be affected
I’m not sure as to what information I could attach regarding system configuration, as I think it’s mostly unrelated, still:
nixos-version
26.11.20260629.b5aa0fb (Zokor)
(via home-manager)
programs.direnv = {
enable = true;
nix-direnv.enable = true;
};
(the flake for the project)
{
description = "A flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-26.05";
nixpkgs-unstable.url = "github:nixos/nixpkgs?ref=nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{
nixpkgs,
nixpkgs-unstable,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
unstable = import nixpkgs-unstable {
inherit system;
config.allowUnfree = true;
};
in
{
devShells.default = pkgs.mkShell {
packages = pkgs.lib.flatten [
(with pkgs; [
bun
nodejs
pnpm
])
(with unstable; [
])
];
shellHook = "";
buildInputs = [ pkgs.bashInteractive ];
};
}
);
}
I’m willing to provide any other information requested as this issue really escapes my knowledge about the nix and direnv ecosystem.
Thanks.