fix: ENAMETOOLONG on Claude Code - write to stdin instead of including the messages in the prompt (#4494)

* Write to stdin instead of including the messages in the prompt

* Add changeset
This commit is contained in:
Tomás Barreiro
2025-06-27 04:13:58 +05:30
committed by GitHub
parent c8f0324536
commit 2709ccefcd
2 changed files with 12 additions and 3 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"claude-dev": patch
---
Fix ENAMETOOLONG when calling Claude Code
+7 -3
View File
@@ -112,7 +112,6 @@ function runProcess({ systemPrompt, messages, path, modelId }: ClaudeCodeOptions
const args = [
"-p",
JSON.stringify(messages),
"--system-prompt",
systemPrompt,
"--verbose",
@@ -129,8 +128,8 @@ function runProcess({ systemPrompt, messages, path, modelId }: ClaudeCodeOptions
args.push("--model", modelId)
}
return execa(claudePath, args, {
stdin: "ignore",
const claudeCodeProcess = execa(claudePath, args, {
stdin: "pipe",
stdout: "pipe",
stderr: "pipe",
env: {
@@ -142,6 +141,11 @@ function runProcess({ systemPrompt, messages, path, modelId }: ClaudeCodeOptions
maxBuffer: 1024 * 1024 * 1000,
timeout: CLAUDE_CODE_TIMEOUT,
})
claudeCodeProcess.stdin.write(JSON.stringify(messages))
claudeCodeProcess.stdin.end()
return claudeCodeProcess
}
function parseChunk(data: string, processState: ProcessState) {