Skip to content

shell: say what a long command line's timeout probably means - #6

Merged
ale-rinaldi merged 1 commit into
mainfrom
fix/timeout-truncation-hint
Sep 5, 2026
Merged

shell: say what a long command line's timeout probably means#6
ale-rinaldi merged 1 commit into
mainfrom
fix/timeout-truncation-hint

Conversation

@ale-rinaldi

Copy link
Copy Markdown
Member

Closes #3.

The problem

Past a limit of its own, a remote shell truncates the typed command line and says nothing at all. The exit-code marker sits at the end of that line, so it goes with it, and -c waits for output that cannot come — then reports:

dwshell: timed out waiting for command to finish

which explains nothing. That is what the reporter of #1 hit, and why they spent time bisecting.

Why not something better

The limits belong to the remote shell and differ by shell — roughly a megabyte with bash/zsh, 4094 characters under sh/dash/ash (the tty cutting a canonical-mode read), 8190 on cmd.exe. dwshell cannot know which shell will answer, so it cannot predict this, and guessing would deny commands the remote would have run.

Detecting it properly was tried and reverted: the probe in v1.3.9 typed an extra line at the remote, which any command reading stdin consumed — dwshell host -c "cat > file" wrote dwshell's own marker into the user's file. Trading a hang for silent data corruption is the worse outcome.

What this does instead

Nothing is added to the wire and nothing is typed at the remote. The timeout reads two things dwshell already has locally — the length of the line it sent, and whether anything ran — and past 4000 characters, the lowest point any measured shell truncates at, names truncation as a possible cause:

dwshell: timed out waiting for command to finish; the command line was 12000
characters, and past a limit of its own the remote shell truncates the line
silently, losing the exit-code marker — if that is what happened here, upload
it with `dwshell put` and run it by path

It stays a possibility, never a diagnosis. A command that is simply still running looks identical from here, which is why the hint is gated on a length that could actually have been cut. Below that length the message is unchanged.

Verification

Case Result
12000-character line, Windows agent hint, naming the length and the workaround
sleep 60 against an 8 s timeout plain message — no misleading hint
Unit tests short line, long line, and nothing-ran

gofmt, go vet, go test -race ./... green.

🤖 Generated with Claude Code

https://claude.ai/code/session_01MvidAFW9a2r4hTgHPW9ywG

Past a limit of its own a remote shell truncates the typed line and says
nothing; the exit-code marker goes with it, so -c waits for output that
cannot come and eventually reports a bare "timed out waiting for command
to finish", which explains nothing.

The limits differ by shell — a megabyte with bash, 4094 characters under
dash, 8190 on cmd.exe — and dwshell cannot know which shell answers, so
it cannot predict this. What it can do is read two things it already
has: how long the line it sent was, and whether anything ran at all.
Past 4000 characters, the lowest point any measured shell truncates at,
the timeout now names truncation as a possible cause and points at
`dwshell put`.

It stays a possibility, never a diagnosis: a command still running looks
the same from here, which is why the hint is gated on a length that
could actually have been cut. Below that length the message is
unchanged.

Nothing is added to the wire and nothing is typed at the remote — the
lesson of the reverted probe (v1.3.9), whose extra typed line was eaten
by commands reading stdin.

Verified live: a 12000-character line on a Windows agent gets the hint,
while `sleep 60` against an 8s timeout still gets the plain message.

Closes #3.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01MvidAFW9a2r4hTgHPW9ywG
@ale-rinaldi
ale-rinaldi merged commit 3ef9201 into main Sep 5, 2026
1 check passed
@ale-rinaldi
ale-rinaldi deleted the fix/timeout-truncation-hint branch September 5, 2026 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

-c hangs instead of erroring when the command exceeds cmd.exe's line limit

1 participant