From b0d5e699c836ea4e51ae91bc9e3d3020c85f7e53 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Wed, 18 Nov 2026 09:03:04 -0500 Subject: [PATCH] starship/jj: set WATCHMAN_SOCK to avoid slow watchman CLI lookup, raise command_timeout --- docs/CHANGELOG.md | 6 ++++++ .../modules/nmasur/presets/programs/jujutsu.nix | 8 ++++++++ .../modules/nmasur/presets/programs/starship.nix | 3 +++ 3 files changed, 17 insertions(+) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 6046a000..f2f83c93 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 2026-11-18: fix starship jj timeout warnings (slow watchman client startup) + +- **Root cause**: starship's jj modules run `jj` several times per prompt, each snapshotting the working copy. With `fsmonitor.backend = "watchman"`, jj's watchman client resolves the socket by running `watchman get-sockname` on every command, and the watchman CLI takes ~110ms just to start (even `watchman --help`). The server itself answers in ~0.4ms. In `platform-api` this made `jj log -r @` take ~140ms (vs ~30ms with no fsmonitor), and parallel jj modules contending for the working-copy lock pushed prompts past starship's 500ms default, logging `Executing command "jj" timed out`. +- **`jujutsu.nix`**: On Darwin, set `WATCHMAN_SOCK` to the server socket so jj skips the CLI lookup (140ms -> 30ms, watchman stays enabled). Caveat: jj can no longer auto-start the watchman server; if it isn't running, jj silently falls back to a full scan. +- **`starship.nix`**: Raised `command_timeout` to 2000ms as a safety net for large snapshots. + ## 2026-11-16: fix occasional terminal crash on zellij switch-session - **Root cause**: the zellij 0.45.1 client leaks one socketpair (2 fds) per `switch-session`. Reproduced with two throwaway sessions: 10 → 33 fds over 12 switches. A client lives as long as its Ghostty window, and macOS gives GUI-launched processes a soft `RLIMIT_NOFILE` of 256 (`launchctl limit maxfiles`). After ~120 switches the client hits EMFILE. Its `assert_socket` liveness probe of the target then fails, so it treats the session as dead and spawns a new server under the same name. That server takes over the socket path, which orphans the real server (still running but unreachable). The new server then panics at `zellij-utils/src/ipc.rs:409` with "Too many open files" and the terminal exits. The log showed this signature three times (2026-11-08, 11-09, 11-16), and each one left a pair of servers sharing a socket name. diff --git a/platforms/home-manager/modules/nmasur/presets/programs/jujutsu.nix b/platforms/home-manager/modules/nmasur/presets/programs/jujutsu.nix index 6b138a17..733f7c39 100644 --- a/platforms/home-manager/modules/nmasur/presets/programs/jujutsu.nix +++ b/platforms/home-manager/modules/nmasur/presets/programs/jujutsu.nix @@ -57,6 +57,14 @@ in ]; }; + # jj's watchman client runs `watchman get-sockname` on every command, and the + # watchman CLI takes ~110ms just to start. Pointing it at the socket directly + # skips that (jj log: 140ms -> 30ms). Caveat: jj then can't auto-start the + # watchman server; if it isn't running, jj silently falls back to a full scan. + home.sessionVariables = lib.optionalAttrs pkgs.stdenv.isDarwin { + WATCHMAN_SOCK = "${config.home.homeDirectory}/.local/state/watchman/${config.home.username}-state/sock"; + }; + home.packages = [ # Required for the fsmonitor to auto-snapshot pkgs.watchman diff --git a/platforms/home-manager/modules/nmasur/presets/programs/starship.nix b/platforms/home-manager/modules/nmasur/presets/programs/starship.nix index 2c5783da..108fbe7b 100644 --- a/platforms/home-manager/modules/nmasur/presets/programs/starship.nix +++ b/platforms/home-manager/modules/nmasur/presets/programs/starship.nix @@ -22,6 +22,9 @@ in enableTransience = true; # Replace previous prompts with custom string settings = { add_newline = false; # Don't print new line at the start of the prompt + # Default is 500ms. The jj modules snapshot the working copy, which can + # exceed that in large repos (e.g. platform-api) and logs WARN timeouts. + command_timeout = 2000; format = lib.concatStrings [ "$directory" "$git_branch"