From 1c9b89cd1c871824dfa79270f1e46ee90b98a106 Mon Sep 17 00:00:00 2001 From: Davide Scaini Date: Sun, 26 Apr 2026 21:16:33 +0200 Subject: [PATCH] fix(dev): raise macOS open-file limit before astro dev to prevent EMFILE --- bincio/dev.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bincio/dev.py b/bincio/dev.py index 8d8751c..3f9ddae 100644 --- a/bincio/dev.py +++ b/bincio/dev.py @@ -7,6 +7,8 @@ foreground. One command replaces the two-terminal setup. from __future__ import annotations import os +import platform +import resource import subprocess import sys import threading @@ -233,6 +235,14 @@ def dev( "VITE_API_PORT": str(api_port), # picked up by astro.config.mjs } + # Astro's file watcher opens many handles; macOS defaults to 256, which + # causes EMFILE. Raise the limit before forking so the child inherits it. + if platform.system() == "Darwin": + target = 65536 + soft, hard = resource.getrlimit(resource.RLIMIT_NOFILE) + if soft < target: + resource.setrlimit(resource.RLIMIT_NOFILE, (min(target, hard), hard)) + # Start astro dev in foreground (Ctrl+C stops everything) console.print(f"Starting [cyan]astro dev[/cyan] on port {port}…") console.print()