From c4146cca672a93fd6ab772ce1f23c7b32712a786 Mon Sep 17 00:00:00 2001 From: Octopus Date: Fri, 3 Apr 2026 10:03:29 +0800 Subject: [PATCH] fix: provide empty JSON fallback when stdin is not piped (fixes #1560) --- plugin/scripts/bun-runner.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/plugin/scripts/bun-runner.js b/plugin/scripts/bun-runner.js index 90ee0997..8135718b 100644 --- a/plugin/scripts/bun-runner.js +++ b/plugin/scripts/bun-runner.js @@ -155,14 +155,17 @@ const stdinData = await collectStdin(); // Note: Don't use shell mode on Windows - it breaks paths with spaces in usernames // Use windowsHide to prevent a visible console window from spawning on Windows const child = spawn(bunPath, args, { - stdio: [stdinData ? 'pipe' : 'ignore', 'inherit', 'inherit'], + stdio: ['pipe', 'inherit', 'inherit'], windowsHide: true, env: process.env }); -// Write buffered stdin to child's pipe, then close it so the child sees EOF -if (stdinData && child.stdin) { - child.stdin.write(stdinData); +// Write buffered stdin to child's pipe, then close it so the child sees EOF. +// Fall back to '{}' when no stdin data is available so worker-service.cjs +// always receives valid JSON input even when Claude Code doesn't pipe stdin +// (e.g. during SessionStart on some platforms). Fixes #1560. +if (child.stdin) { + child.stdin.write(stdinData || '{}'); child.stdin.end(); }