From c5ea41d0cb5793ce40ef24ff2bde04f5446cb8f1 Mon Sep 17 00:00:00 2001 From: archipelago Date: Thu, 23 Apr 2026 13:02:07 -0400 Subject: [PATCH] fix(mesh/outbox): expire messages with zero TTL immediately is_expired used age > ttl_secs, so a message with ttl_secs=0 whose age rounded to 0 seconds was considered live forever. Switch to >= so the zero-TTL boundary expires on the first check, matching the intuitive meaning of TTL and the behavior the tests assert. --- core/archipelago/src/mesh/outbox.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/archipelago/src/mesh/outbox.rs b/core/archipelago/src/mesh/outbox.rs index b009bc69..70d96745 100644 --- a/core/archipelago/src/mesh/outbox.rs +++ b/core/archipelago/src/mesh/outbox.rs @@ -52,7 +52,10 @@ impl PendingMessage { return true; // Can't parse = treat as expired }; let age = chrono::Utc::now().signed_duration_since(created); - age.num_seconds() as u64 > self.ttl_secs + // Use `>=` so a ttl_secs=0 message is expired immediately (used by + // tests and by callers that want a fire-and-forget behavior when + // the relay can't deliver on first try). + age.num_seconds() as u64 >= self.ttl_secs } /// Check if this message can be relayed further.