From 67f5ee8df534ea8ae7b275e0addf8c7949e2cb3d Mon Sep 17 00:00:00 2001 From: Ingmar Delsink Date: Sun, 5 Nov 2023 16:39:26 +0100 Subject: [PATCH] Fix: Access container memory_stats.stats safely by optional chaining (#2271) (#2272) --- src/widgets/docker/stats-helpers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/docker/stats-helpers.js b/src/widgets/docker/stats-helpers.js index 7f3894b41..3e184e8a0 100644 --- a/src/widgets/docker/stats-helpers.js +++ b/src/widgets/docker/stats-helpers.js @@ -13,6 +13,6 @@ export function calculateCPUPercent(stats) { export function calculateUsedMemory(stats) { // see https://github.com/docker/cli/blob/dcc161076861177b5eef6cb321722520db3184e7/cli/command/container/stats_helpers.go#L239 return ( - stats.memory_stats.usage - (stats.memory_stats.total_inactive_file ?? stats.memory_stats.stats.inactive_file ?? 0) + stats.memory_stats.usage - (stats.memory_stats.total_inactive_file ?? stats.memory_stats.stats?.inactive_file ?? 0) ); }