diff --git a/src/metrics.js b/src/metrics.js index 15147fcdf..283f268c8 100644 --- a/src/metrics.js +++ b/src/metrics.js @@ -28,8 +28,8 @@ const apps = require('./apps.js'), async function readContainerMetric(name) { assert.strictEqual(typeof name, 'string'); - const stats = await docker.getStats(name); - if (Object.keys(stats.memory_stats).length === 0) return null; // the container is stopped. better not to inspect and check State since a race is possible + const [error, stats] = await safe(docker.getStats(name)); + if (error || Object.keys(stats.memory_stats).length === 0) return null; // the container is missing or stopped. better not to inspect and check State since a race is possible const networkRead = stats.networks ? stats.networks.eth0.rx_bytes : 0; // in host mode (turn), networks is missing const networkWrite = stats.networks ? stats.networks.eth0.tx_bytes : 0; // in host mode (turn), networks is missing