fix(arr): re-read the command timeout every batch

This commit is contained in:
Miguel Palhas
2026-08-25 03:15:33 +01:00
parent 4003c3a5a0
commit 47c7ef6682
2 changed files with 65 additions and 4 deletions
+32
View File
@@ -237,4 +237,36 @@ async fn a_hanging_command_is_killed_at_the_timeout() {
}
}
/// Issue #219: the timeout is not frozen at construction. The settings API
/// stores the row's value into [`Command::timeout_cell`] on every edit, and
/// the next batch must already run under it.
#[tokio::test]
async fn an_edited_timeout_reaches_the_next_call() {
let dir = tempfile::tempdir().expect("tempdir");
let script = stub(dir.path(), "hang.sh", "sleep 30\n");
let backend =
Command::new(config(&script.display().to_string(), DEFAULT)).expect("backend constructs");
// The edit that a PUT of remote_command_timeout_seconds performs.
backend
.timeout_cell()
.store(150, std::sync::atomic::Ordering::Relaxed);
let error = translate(
&backend,
&cues(&["hello"]),
&Language::Other("en".to_owned()),
&Language::PortuguesePortugal,
)
.await
.expect_err("the edited timeout must apply without a restart");
match error {
Error::Transport { source, .. } => {
assert!(source.to_string().contains("150ms"), "{source}");
}
other => panic!("expected Transport, got {other:?}"),
}
}
const DEFAULT: Duration = arr_subs::COMMAND_DEFAULT_TIMEOUT;