Skip to content

fix: report the timeout when a command succeeds past the deadline - #173

Open
ferdingler wants to merge 1 commit into
strands-agents:mainfrom
ferdingler:fix/sleep-deadline-status
Open

ferdingler wants to merge 1 commit into
strands-agents:mainfrom
ferdingler:fix/sleep-deadline-status

Conversation

@ferdingler

Copy link
Copy Markdown
Collaborator

Description

Under a timeout, sleep 5 with a two second limit came back with status 0 and no error, as if it had slept the whole time. Sleep stops when the deadline hits, but the shell only notices the timeout before it starts the next command. So if the sleep was the last thing in the line, or sat behind || or in a pipeline, the timeout went unreported.

Now the shell also checks the deadline right after a command that claims success, and reports the usual timeout error with status 1. I put the check in the shell rather than in sleep itself, because sleep can't stop the rest of the line, and if it printed the error the shell would print it a second time for whatever came next. Commands that already fail on the timeout (like Lua or a busy loop) behave the same as before. One thing I left alone: a timeout inside a subshell followed by another command still prints the error twice, same as a busy loop does there today.

I added a test that a sleep past the deadline fails with the timeout error, and a control that a short sleep under a generous timeout still succeeds. On main the first one fails; with the change both pass, and they ran clean five times in a row. The full Rust suite, the doc tests and the node-feature tests pass, and clippy shows no new warnings.

Related Issues

None.

Documentation PR

None.

Type of Change

Bug fix

Testing

How have you tested the change? Verify that the changes do not break functionality or introduce new warnings.

  • I ran the relevant test suites for the bindings I touched (cargo test --workspace --all-targets, pytest tests/python, npm test)
  • If I touched Rust, I ran cargo fmt and cargo clippy

Checklist

  • I have read the CONTRIBUTING document
  • I have reviewed and understand every line of code in this PR, including any generated by AI tools, and I can explain why it works
  • My change is focused and reasonably small; I have split unrelated work into separate PRs
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

sleep stops at the deadline and exits 0, and the shell only checks the
deadline before the next command. So a timed-out sleep at the end of a
command line, after ||, or in a pipeline reported success with no
error. Check the deadline after a command that exits 0 as well, so the
timeout is reported once, with status 1.

This branch has not been deployed

No deployments
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