mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-22 16:25:51 +00:00
fix: 修复 Node.js 环境下 UDS socket chmod ENOENT 导致进程无输出退出
macOS + Node.js v22 中,嵌套目录路径的 Unix Domain Socket 在 listen 回调触发时文件可能尚未落盘,chmod 随即抛出 ENOENT, 导致 startUdsMessaging → setup() 整条链路崩溃。将 chmod 改为 非致命操作,ENOENT 时安全跳过(父目录已为 0o700)。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -557,7 +557,26 @@ export async function startUdsMessaging(
|
|||||||
void (async () => {
|
void (async () => {
|
||||||
try {
|
try {
|
||||||
if (process.platform !== 'win32') {
|
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.off('error', rejectBeforeListen)
|
||||||
srv.on('error', logRuntimeError)
|
srv.on('error', logRuntimeError)
|
||||||
|
|||||||
Reference in New Issue
Block a user