Skip to content

Clamp the bash foreground timeout to the 32-bit timer limit - #438

Merged
ilovepixelart merged 1 commit into
mainfrom
fix/bash-timeout-clamp
Nov 15, 2026
Merged

ilovepixelart merged 1 commit into
mainfrom
fix/bash-timeout-clamp

Conversation

@ilovepixelart

Copy link
Copy Markdown
Owner

foregroundLimitMs in extensions/background-bash.ts had no upper bound, so a timeout above 2147483647 ms reached setTimeout and pi's built-in bash unchanged.

With BASH_DEFAULT_TIMEOUT_MS=3000000000 and the command echo a; sleep 2; echo b:

Session Before After
with a UI "Command did not complete within its 3000000s timeout and was moved to the background" after 1 ms, with Node's TimeoutOverflowWarning a\nb
without a UI Invalid timeout: maximum is 2147483.647 seconds a\nb

The same was reachable with a large BASH_MAX_TIMEOUT_MS and a large model-supplied timeout.

The limit is now capped at 2147483647 ms, the longest delay a timer holds and the largest timeout pi's bash accepts. Claude Code 2.1.325 accepts the same value and runs the command normally.

  • npm run check passes (Biome, strict tsc, Vitest)
  • Tests cover the change

With BASH_DEFAULT_TIMEOUT_MS=3000000000, or a BASH_MAX_TIMEOUT_MS and a
requested timeout above 2147483647 ms, foregroundLimitMs returned the
value unbounded:

- with a UI, setTimeout overflowed and fired after 1 ms, so
  `echo a; sleep 2; echo b` returned "Command did not complete within its
  3000000s timeout and was moved to the background" at once, with a
  TimeoutOverflowWarning;
- without a UI, the value reached pi's bash as seconds and every call
  failed with "Invalid timeout: maximum is 2147483.647 seconds".

foregroundLimitMs now returns at most 2147483647 ms, the largest timeout
the timer and pi's bash accept, so an oversized value runs the command
as Claude Code does. The schema text then states 2147483.647 seconds.
@sonarqubecloud

Copy link
Copy Markdown

@ilovepixelart
ilovepixelart merged commit a22e71d into main Nov 15, 2026
13 checks passed
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.

1 participant