From c81dac8c3c0d93d7c963aedfc851d21aeab16f74 Mon Sep 17 00:00:00 2001 From: claude-code-best Date: Mon, 27 Apr 2026 20:48:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20Node.js=20=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E4=B8=8B=20UDS=20socket=20chmod=20ENOENT=20=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E8=BF=9B=E7=A8=8B=E6=97=A0=E8=BE=93=E5=87=BA=E9=80=80?= =?UTF-8?q?=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit macOS + Node.js v22 中,嵌套目录路径的 Unix Domain Socket 在 listen 回调触发时文件可能尚未落盘,chmod 随即抛出 ENOENT, 导致 startUdsMessaging → setup() 整条链路崩溃。将 chmod 改为 非致命操作,ENOENT 时安全跳过(父目录已为 0o700)。 Co-Authored-By: Claude Opus 4.7 --- src/utils/udsMessaging.ts | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/utils/udsMessaging.ts b/src/utils/udsMessaging.ts index b30cba137..85d1c1cdd 100644 --- a/src/utils/udsMessaging.ts +++ b/src/utils/udsMessaging.ts @@ -557,7 +557,26 @@ export async function startUdsMessaging( void (async () => { try { if (process.platform !== 'win32') { - await chmod(path, 0o600) + // Restrict socket permissions to owner-only. On macOS with + // Node.js v22, the listen callback may fire before the socket + // file is visible on disk (observed with nested tmpdir paths). + // The parent directory is already 0o700, so skipping chmod when + // the file is not yet visible is safe. + try { + await chmod(path, 0o600) + } catch (err: unknown) { + if ( + !( + err instanceof Error && + (err as NodeJS.ErrnoException).code === 'ENOENT' + ) + ) { + throw err + } + logForDebugging( + `[udsMessaging] chmod skipped: socket file not yet visible at ${path}`, + ) + } } srv.off('error', rejectBeforeListen) srv.on('error', logRuntimeError)