mirror of
https://github.com/nmasur/dotfiles
synced 2026-11-18 18:19:14 +00:00
zellij: raise fd soft limit to stop switch-session crashes
This commit is contained in:
1 parent
04ab27d16c
commit
a17cb837b0
2 files changed
+23
-2
No files matched your search
@@ -1,5 +1,11 @@
|
||||
# Changelog
|
||||
|
||||
## 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.
|
||||
- **`zellij.nix`**: Ghostty's `initial-command` now goes through a `zellij-high-nofile` wrapper that raises the soft fd limit to 65536 before `exec zellij`, so the leak would need ~32k switches in one window to matter.
|
||||
- **`zellij.nix`**: `zellij-switch-to-last` used `return 1` outside a function, which bash rejects and then carries on. It now uses `exit 1`, so an empty last-session file no longer overwrites the state file and runs `switch-session` with no name.
|
||||
|
||||
## 2026-11-15: update api flake input to bump @actual-app/api to 26.10.0 and fix caddy build
|
||||
|
||||
- **`flake.lock`**: Updated `api` input (`github:nmasur/api`) from `55e0de89` to `4e310cf4` so `api-actual` uses `@actual-app/api` 26.10.0 matching `actual-server` 26.10.0 (`1787013118115_add_account_groups.sql`) and resolves `out-of-sync-migrations` errors on `budget1`.
|
||||
|
||||
@@ -20,10 +20,24 @@ let
|
||||
exec ${lib.getExe pkgs.fish} "$@"
|
||||
'';
|
||||
|
||||
# The zellij 0.45.1 client leaks one socketpair (2 fds) on every
|
||||
# switch-session, and a client lives as long as its Ghostty window. macOS
|
||||
# gives GUI-launched processes a soft RLIMIT_NOFILE of 256, so after ~120
|
||||
# switches in one window the client hits EMFILE. Its liveness probe of the
|
||||
# target session then fails, it decides the session is dead, and it spawns a
|
||||
# replacement server under the same name. That server steals the socket
|
||||
# path (orphaning the real, still-running server), inherits the leaked fds,
|
||||
# panics with "Too many open files", and takes the terminal down. Raising the
|
||||
# soft limit makes the leak harmless in practice.
|
||||
zellij-high-nofile = pkgs.writeShellScriptBin "zellij-high-nofile" ''
|
||||
ulimit -Sn 65536 2>/dev/null || ulimit -Sn "$(ulimit -Hn)" 2>/dev/null
|
||||
exec ${lib.getExe pkgs.zellij} "$@"
|
||||
'';
|
||||
|
||||
zellij-switch-to-last = pkgs.writeShellScriptBin "zellij-switch-to-last" ''
|
||||
TARGET_SESSION=$(cat ~/.local/state/zellij-last-session)
|
||||
if [ -z "$TARGET_SESSION" ]; then
|
||||
return 1
|
||||
exit 1
|
||||
fi
|
||||
echo "$ZELLIJ_SESSION_NAME" > ~/.local/state/zellij-last-session
|
||||
${lib.getExe pkgs.zellij} action switch-session $TARGET_SESSION
|
||||
@@ -98,7 +112,8 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
programs.ghostty.settings.initial-command = lib.getExe pkgs.zellij;
|
||||
# Launch through the fd-limit wrapper; see zellij-high-nofile above.
|
||||
programs.ghostty.settings.initial-command = lib.getExe zellij-high-nofile;
|
||||
|
||||
xdg.configFile."zellij/layouts/compact-top.kdl".text = # kdl
|
||||
''
|
||||
|
||||
Reference in new issue
Block a user