mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-26 04:15:48 -06:00
fix(infra): add NaN guard for unparseable timestamp in session-cost-usage (#99420)
new Date(parsed.timestamp).getTime() can return NaN for unparseable strings. Without a guard, NaN silently propagates into downstream usage/cost calculations and corrupts billing data. Add Number.isNaN(timestamp) check, falling back to 0 (same default as the path when no timestamp key is present). Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2743,6 +2743,9 @@ export async function loadSessionLogs(params: {
|
||||
let timestamp = 0;
|
||||
if (typeof parsed.timestamp === "string") {
|
||||
timestamp = new Date(parsed.timestamp).getTime();
|
||||
if (Number.isNaN(timestamp)) {
|
||||
timestamp = 0;
|
||||
}
|
||||
} else if (typeof message.timestamp === "number") {
|
||||
timestamp = message.timestamp;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user