The week of November 2, the disk on my Mac Mini filled up and took my assistant platform down with it. No warning. Jobs stopped, chat stopped, and I found out the way I always find out: something I asked for didn't happen.
The Mini runs Claudia, the agent system that handles my scheduled jobs, chat, and a pile of background work. The disk filled with training artifacts and stored models from a side project I'd already shut down. I moved them to a USB thumb drive that afternoon, which was a patch, not a fix.
So last Sunday I sat down to fix it properly. By evening I had a disk watch, a network share on my Windows PC for heavy files, and a lesson about what a health check is allowed to touch.
The plan
Two pieces. First, a watch in the worker: every 15 minutes, read free space on the data volume. Push a phone alert at 80% and 90%, name the folders that grew, and at 95% stop claiming new jobs until it drops under 92%. It reports and never deletes.
Second, stop storing big things on the Mini at all. My Windows PC has terabytes free and stays on. I created a dedicated Windows account with access to one folder, shared it, and wrote a small launchd keeper that mounts it on the Mini at ~/pc-store/pc and remounts it if it drops. Jobs get a line in their system prompt: models, datasets, images, and anything over a gigabyte go there.
The disk watch got one more job: if the share is mounted, report its usage too. Before counting it, check that the mount point exists.
if (existsSync(mountPath)) { /* statfs it */ }
That line passed every test. Thirteen of them.
Thirty minutes later
Here's the chain, in order.
The keeper's health check used ls on the share. macOS refused it, because a bash started by launchd doesn't get to read network volumes under the privacy rules. So the keeper decided the share was down and remounted it. Every two minutes.
Meanwhile a job tried to read the share from inside tmux, which is how every Claudia job runs. macOS treats tmux as its own app. tmux had never been granted access to network volumes, so the read didn't fail. It hung, waiting on a permission prompt sitting on the Mini's screen where nobody would see it.
Then the keeper, on schedule, tried to unmount the stale-looking share while that read was pending. The umount got stuck in the kernel. The mount point was now wedged: any process that so much as stats that path goes into uninterruptible sleep, state U in ps.
And my disk watch, the code I'd written that afternoon so the Mini would never go down silently, called existsSync() on that exact path.
The worker froze. So did du and df when I tried them. Chat kept working, because it runs in a different process, which made the whole thing look half-alive. Scheduled jobs and checks stopped for about seventeen minutes. Closing the SMB session from the Windows side released nothing. The only fix was restarting the Mini, which with FileVault on and no auto-login means unlocking the disk over SSH and then signing in by Screen Sharing.
Why a timeout wouldn't have saved me
My first instinct was to wrap the risky calls in a timeout. That doesn't work here, and the reason is the part I keep thinking about.
existsSync() is synchronous. It runs on Node's main thread. When the kernel parks it, the event loop parks with it, and no timer will ever fire. Even moving to the async version only moves the problem: an async statfs on a wedged mount pins a libuv thread pool slot forever, and there are only four by default.
Shelling out with execFile and its timeout option fails a different way. At the deadline Node sends a kill signal, then waits for the child to exit. A process in state U can't be killed. It will exit when the kernel lets it go, which on that Sunday was never.
So the rule I landed on: the worker never touches the mount path directly, and anything that does touch it runs in a child process the worker is willing to abandon.
const timer = setTimeout(() => {
try { child.kill("SIGKILL"); } catch { /* may be unkillable */ }
child.stdout.destroy();
child.unref();
finish(null);
}, ms);
runWithDeadline() spawns the command detached, and at the deadline it tries a kill, stops listening, unrefs the child, and resolves null. If the child is stuck in the kernel, it stays stuck, but it's no longer the worker's problem. A leaked zombie is a better failure than a frozen scheduler.
The rest of the fixes
- "Is it mounted?" comes from the mount table, never from the path. Reading the table is a syscall about the system, not about the mount, so a wedged share can't hang it.
duskips the share with-I pc-store, so the folder-size scan can't walk into it.- The keeper checks health with
df, which launchd's bash is allowed to run, so it stopped remounting every two minutes. - Jobs only get the "big files go to the PC" instruction after a real probe. A throwaway tmux session has to
lsthe share within eight seconds. The worker being able to read the share proves nothing about jobs, because they run in a different app as far as macOS is concerned. - The probe re-runs every six hours. The tmux permission is tied to its Homebrew path, so a
brew upgrade tmuxquietly drops it. The next probe catches that and pushes.
What I'm keeping from this
The watch was supposed to be the most boring code on the machine. That's exactly why I didn't look hard at it. It ran on a timer, in the worker's own process, against a path I'd added the same afternoon, and nothing about existsSync() reads as dangerous.
The question I ask about a monitor now is what it does when the thing it's watching is broken in the worst possible way. Not down, which is easy to report, but hung. If the answer is "it hangs too," then the monitor shares a failure mode with the system and adds one more way to lose it.
The share has been up since the restart. I copied 82 files, about 40 GB of old training data, onto it with sizes matching on both sides, and the thumb drive is empty again. The worker's log has a line I like reading: job access to the PC share, OK.

