Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(cache): restore missing cache entry on read

Steven Enamakel96e0ff57ec88
diff --git a/crates/openhuman-session/src/cache.rs b/crates/openhuman-session/src/cache.rs
index c728da7dea..d8fc581329 100644
--- a/crates/openhuman-session/src/cache.rs
+++ b/crates/openhuman-session/src/cache.rs
@@ -267,8 +267,14 @@ impl CurrentUserCache {
let generation = self.lock().generation;
if !force {
- if let Some(error) = self.suppressed_error(&key) {
- return Err(error);
+ // A rejection is authoritative regardless of what else is cached:
+ // a stale-while-revalidate caller cannot observe a background
+ // rejection directly, so it must be surfaced now rather than
+ // served through on a positive entry that predates it.
+ if let Some((error, _, _)) = self.suppressed(&key) {
+ if matches!(error, FetchMeError::Rejected(_)) {
+ return Err(error);
+ }
}
if let Some((user, age)) = self.cached(&key) {
if age < REFRESH_TTL {
@@ -281,6 +287,13 @@ impl CurrentUserCache {
);
return Ok(self.with_result(&key, Some(user)));
}
+ // No positive entry to fall back on: only now does an open
+ // availability-backoff window turn into an error, instead of
+ // pre-empting perfectly good cached data for the whole window
+ // (#6318 review follow-up).
+ if let Some(error) = self.suppressed_error(&key) {
+ return Err(error);
+ }
}
// The first caller owns the network refresh. Concurrent cache misses