Skip to content

Commit c8f5beb

Browse files
kriszypclaude
andcommitted
fix(stress): extend optional chain through .trim() in readHostCounters
?.[1] short-circuits to undefined when /proc/stat's cpu line is missing, but the following .trim() ran unconditionally and threw before the ?? [] fallback could apply — breaking readHostCounters' "return null for any source the platform lacks" contract and surfacing as an uncaught exception in the setInterval sampling callback. Addresses PR #617 review threads from gemini-code-assist and claude. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 88acca6 commit c8f5beb

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

integrationTests/stress/stressShared.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export function readHostCounters() {
6363
const cpu =
6464
stat
6565
.match(/^cpu\s+(.*)$/m)?.[1]
66-
.trim()
66+
?.trim()
6767
.split(/\s+/)
6868
.map(Number) ?? [];
6969
const [, , , idle = 0, iowait = 0, , , steal = 0] = cpu;

0 commit comments

Comments
 (0)