fix(processmonitor): Skip null pidusage entries when aggregating process-group memory/CPU to avoid errors

This commit is contained in:
2025-09-03 08:27:06 +00:00
parent e208384d41
commit 3a39fbd65f
3 changed files with 15 additions and 3 deletions

View File

@@ -1,5 +1,12 @@
# Changelog
## 2025-09-03 - 5.10.1 - fix(processmonitor)
Skip null pidusage entries when aggregating process-group memory/CPU to avoid errors
- Add defensive check for null/undefined entries returned by pidusage before accessing memory/cpu fields
- Log a debug message when an individual process stat is null (process may have exited)
- Improve robustness of ProcessMonitor.getProcessGroupStats to prevent runtime exceptions during aggregation
## 2025-09-01 - 5.10.0 - feat(daemon)
Add crash log manager with rotation and integrate crash logging; improve IPC & process listener cleanup

View File

@@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@git.zone/tspm',
version: '5.10.0',
version: '5.10.1',
description: 'a no fuzz process manager'
}

View File

@@ -435,8 +435,13 @@ export class ProcessMonitor extends EventEmitter {
let totalMemory = 0;
let totalCpu = 0;
for (const key in stats) {
totalMemory += stats[key].memory;
totalCpu += Number.isFinite(stats[key].cpu) ? stats[key].cpu : 0;
// Check if stats[key] exists and is not null (process may have exited)
if (stats[key]) {
totalMemory += stats[key].memory || 0;
totalCpu += Number.isFinite(stats[key].cpu) ? stats[key].cpu : 0;
} else {
this.logger.debug(`Process ${key} stats are null (process may have exited)`);
}
}
this.logger.debug(