Spaces:
Runtime error
Runtime error
Fix: never emit Infinity in health JSON (strict JSON for browsers)
Browse files659 unmodified lines6606616626636636646656662 unmodified lines669670671672673672674675676677235 unmodified lines913914915914916917918919920921659 unmodified lines """Check if state is stale (not updated recently)."""
last = self._last_write.get('state', 0)
if last == 0:
return True, float('inf')
return True, -1.0 # never written; -1.0 = unknown (never Infinity — strict JSON)
age = time.time() - last
return age > self._stale_threshold, age
2 unmodified lines last = self._last_write.get('state', 0)
return {
'last_write': datetime.fromtimestamp(last).isoformat() if last > 0 else 'NEVER',
# None when never written: float('inf') would serialize as the literal
# `Infinity` token, which browsers cannot JSON.parse.
'age_seconds': now - last if last > 0 else float('inf'),
'age_seconds': now - last if last > 0 else None,
'is_stale': (now - last > self._stale_threshold) if last > 0 else True,
'write_count': self._write_count,
}235 unmodified lines
if state_freshness['is_stale']:
health = 'degraded' if health == 'healthy' else health
issues.append(f"State stale: {state_freshness['age_seconds']:.0f}s old")
age = state_freshness.get('age_seconds')
stale_detail = 'never written' if age is None else f"{age:.0f}s old"
issues.append(f"State stale: {stale_detail}")
return {
'status': health,aureon/core/aureon_operational_core.py+7-3