fix: clamp poll sleep duration to non-negative in bash-tools process (#24889)

`Math.min(250, deadline - Date.now())` could return a negative value if
the deadline expired between the while-condition check and the setTimeout
call. Wrap with `Math.max(0, ...)` to ensure the sleep is never negative.

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Adam 2026-02-23 19:22:58 -08:00 committed by GitHub
parent dc8423f2c0
commit d07d24eebe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 1 deletions

View File

@ -331,7 +331,7 @@ export function createProcessTool(
const deadline = Date.now() + pollWaitMs;
while (!scopedSession.exited && Date.now() < deadline) {
await new Promise((resolve) =>
setTimeout(resolve, Math.min(250, deadline - Date.now())),
setTimeout(resolve, Math.max(0, Math.min(250, deadline - Date.now()))),
);
}
}