nanocoder icon indicating copy to clipboard operation
nanocoder copied to clipboard

[Bug] execute_bash leaves the command's stdin open, so prompts and editors hang until the 2 minute timeout

Open akramcodez opened this issue 3 weeks ago • 2 comments

Description

execute_bash starts the command with a stdin pipe that is never written to or closed. Any command that waits for input (an interactive prompt, cat with no file, a git command that opens an editor) hangs until the 2 minute timeout kills it.

Environment

  • OS: macOS 27.2
  • Node version: v22.23.4
  • Nanocoder version: 1.32.0 (main at daa0ad9b)
  • Provider: not provider specific
  • Model: not model specific

Steps to Reproduce

In source/services/bash-executor.ts the non-Windows path does:

proc = spawn('sh', ['-c', spawnCommand], {cwd, detached: true, env: childEnv});

There is no stdio option, so Node uses ['pipe', 'pipe', 'pipe'], and the only place stdin is touched is process.stdin?.destroy() when a run is cancelled. I reproduced the same spawn options outside the app:

  1. Run sh -c 'read -p "Project name? " name; echo got:$name' with those options. It never exits (I killed it after 3 seconds).
  2. Same command with stdio: ['ignore', 'pipe', 'pipe'] exits immediately with got:.
  3. cat and git commit (with an editor that reads input) behave the same: hang with the current options.

In the app: ask the agent to run something like npm init, npx create-vite, git commit without -m, or python with no script.

Expected Behavior

A command that needs input should fail fast (EOF on stdin), so the model sees the error or prompt text and can retry with flags such as -y or -m.

Actual Behavior

The tool call sits there for the full 2 minutes, with the progress spinner running, and the model gets a timeout with little useful output. Interactive scaffolding commands are a common thing for a model to try, so this costs real time.

Logs/Screenshots

Output of my standalone repro (3 second cap):

current spawn options  : HUNG (killed after 3s)
with stdin "ignore"    : exit 0 8ms "got:"
current: cat           : HUNG (killed after 3s)
current: git commit    : HUNG (killed after 3s)

Additional Context

  • [x] I have searched existing issues to ensure this is not a duplicate
  • [x] I can reproduce this issue consistently
  • [x] This issue occurs with the latest version of nanocoder

Suggested fix: pass stdio: ['ignore', 'pipe', 'pipe'] for the Unix path (and the equivalent on the Windows and sandbox paths), and set GIT_TERMINAL_PROMPT=0, GIT_EDITOR=true and PAGER=cat in the child env. #1344 did the stdin and prompt part for the git tools, but execute_bash was not covered.

akramcodez avatar Nov 06 '26 09:11 akramcodez

Hi @pcbeingused333, thanks for your work on this! Could you please leave a quick comment on this issue so I can assign it to you? Going forward, please comment on an issue first and wait to be assigned before you start working on it. That way we avoid duplicate work and keep things fair for everyone. Thanks for contributing!

addyCooks avatar Nov 07 '26 08:11 addyCooks

Hi @addyCooks, thanks for the heads-up, and sorry for opening #1984 before being assigned. I'd like to take this issue: execute_bash leaves the child's stdin open, so interactive prompts and editors block until the 2-minute timeout. #1984 closes stdin for the spawned command and adds a test. Could you assign it to me? From now on I'll comment on an issue and wait to be assigned before starting work on it.


This comment was prepared with the help of an AI coding assistant (Claude Code) and submitted by Alex Castillo González.

pcbeingused33 avatar Nov 07 '26 11:11 pcbeingused33