fix: 系统性能内存读取避开低版本 TS 的 BigInt 字面量

This commit is contained in:
chenpei 2026-08-17 13:41:19 +08:00
parent e864fc3249
commit 39954b1424

View File

@ -17,7 +17,7 @@ const CGROUP_V2_CURRENT = '/sys/fs/cgroup/memory.current'
const CGROUP_V2_MAX = '/sys/fs/cgroup/memory.max'
const CGROUP_V1_USAGE = '/sys/fs/cgroup/memory/memory.usage_in_bytes'
const CGROUP_V1_LIMIT = '/sys/fs/cgroup/memory/memory.limit_in_bytes'
const CGROUP_UNLIMITED = 1n << 60n
const CGROUP_UNLIMITED = BigInt(1) << BigInt(60)
type FileReader = (path: string) => Promise<string>
@ -26,7 +26,7 @@ async function readNumericFile(read: FileReader, path: string): Promise<bigint |
const raw = (await read(path)).trim()
if (!raw || raw === 'max') return null
const value = BigInt(raw)
return value >= 0n ? value : null
return value >= BigInt(0) ? value : null
} catch {
return null
}