From 270f9f854add8db84fadc0a96e127a6035128aef Mon Sep 17 00:00:00 2001 From: Cameron Diver Date: Wed, 8 Jul 2020 11:58:53 +0100 Subject: [PATCH] Fix bug where a promise was not resolved in db-format Change-type: patch Signed-off-by: Cameron Diver --- src/device-state/db-format.ts | 36 +++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/src/device-state/db-format.ts b/src/device-state/db-format.ts index 75dc5e0b..3f4d13ba 100644 --- a/src/device-state/db-format.ts +++ b/src/device-state/db-format.ts @@ -66,20 +66,28 @@ async function buildApp(dbApp: targetStateCache.DatabaseApp) { }, ); - const opts = await config.get('extendedEnvOptions'); - const supervisorApiHost = dockerUtils - .getNetworkGateway(constants.supervisorNetworkInterface) - .catch(() => '127.0.0.1'); - const hostPathExists = { - firmware: await pathExistsOnHost('/lib/firmware'), - modules: await pathExistsOnHost('/lib/modules'), - }; - const hostnameOnHost = _.trim( - await fs.readFile( - path.join(constants.rootMountPoint, '/etc/hostname'), - 'utf8', - ), - ); + const [ + opts, + supervisorApiHost, + hostPathExists, + hostnameOnHost, + ] = await Promise.all([ + config.get('extendedEnvOptions'), + dockerUtils + .getNetworkGateway(constants.supervisorNetworkInterface) + .catch(() => '127.0.0.1'), + (async () => ({ + firmware: await pathExistsOnHost('/lib/firmware'), + modules: await pathExistsOnHost('/lib/modules'), + }))(), + (async () => + _.trim( + await fs.readFile( + path.join(constants.rootMountPoint, '/etc/hostname'), + 'utf8', + ), + ))(), + ]); const svcOpts = { appName: dbApp.name,