Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

Name the local network filter when yt-dlp's connect() fails with EBADF

[._.]/ Adam Eivy7e4aa58ce137
diff --git a/server/services/ytdlpRun.js b/server/services/ytdlpRun.js
index 87d3e754be..a546c593ef 100644
--- a/server/services/ytdlpRun.js
+++ b/server/services/ytdlpRun.js
@@ -85,6 +85,18 @@ const STALE_YTDLP_SIGNATURE = /HTTP Error 403|PO Token|nsig|Failed to extract an
const STALE_YTDLP_HINT = 'the installed yt-dlp is likely out of date for YouTube\'s current player — update it (`yt-dlp -U`, or `brew upgrade yt-dlp`) and retry';
+/**
+ * `connect()` failing with EBADF is not a network fault: it is how a macOS
+ * outbound filter (Little Snitch, or another NetworkExtension) reports a DENIED
+ * connection — seen both from a stale per-binary rule after a Homebrew upgrade
+ * and from the filter's extension staying loaded while its app was not running.
+ * It reads like an x.com or yt-dlp bug, and an upgrade cannot fix it,
+ * so it gets its own source-agnostic remedy.
+ */
+const BLOCKED_CONNECT_SIGNATURE = /Failed to establish a new connection: \[Errno 9\] Bad file descriptor/i;
+
+const BLOCKED_CONNECT_HINT = 'the connection was blocked on this machine, which usually means an outbound network filter (e.g. Little Snitch) denied yt-dlp — check that the filter is running and allows yt-dlp and its Python, then retry';
+
/**
* Compose the user-facing reason for a failed yt-dlp run.
*
@@ -107,6 +119,7 @@ export function describeYtDlpFailure(code, output, { fallback, url } = {}) {
const base = fallback
? [fallback, said].filter(Boolean).join(' — yt-dlp said: ')
: (said ? `yt-dlp failed: ${said}` : `yt-dlp exited ${code}`);
+ if (BLOCKED_CONNECT_SIGNATURE.test(said)) return `${base} — ${BLOCKED_CONNECT_HINT}`;
const stalePlayer = isYoutubeVideoUrl(url) && STALE_YTDLP_SIGNATURE.test(said);
return stalePlayer ? `${base} — ${STALE_YTDLP_HINT}` : base;
}
diff --git a/server/services/ytdlpRun.test.js b/server/services/ytdlpRun.test.js
index 982eef0589..ff369106fe 100644
--- a/server/services/ytdlpRun.test.js
+++ b/server/services/ytdlpRun.test.js
@@ -85,6 +85,16 @@ describe('describeYtDlpFailure', () => {
expect(reason).not.toMatch(/yt-dlp -U/);
});
+ // EBADF on connect is a local outbound filter denying the binary, on any
+ // site; the upgrade advice would be the wrong remedy.
+ it('names the local network filter when connect() fails with EBADF', () => {
+ const blocked = "ERROR: [twitter] 1: Unable to download JSON metadata: HTTPSConnection(host='api.x.com', port=443): Failed to establish a new connection: [Errno 9] Bad file descriptor";
+ const reason = describeYtDlpFailure(1, blocked, { url: X_URL });
+ expect(reason).toContain('[Errno 9] Bad file descriptor');
+ expect(reason).toMatch(/network filter/);
+ expect(reason).not.toMatch(/yt-dlp -U/);
+ });
+
it('withholds the hint when the caller passed no URL at all', () => {
expect(describeYtDlpFailure(1, FORBIDDEN)).not.toMatch(/yt-dlp -U/);
});