From c0b97711efab8e979fb86a5ed104e745a364281f Mon Sep 17 00:00:00 2001 From: Eric Vera <6858503+ericvera@users.noreply.github.com> Date: Fri, 30 Sep 2022 13:33:04 -0400 Subject: [PATCH] Allow emulators to work offline (MOTD fail) (#4998) * Allow emulators to work offline (MOTD fail) * Allow process to continue when MOTD fetch fails * Run prettier on CHANGELOG.md Co-authored-by: Bryan Kendall --- src/fetchMOTD.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/fetchMOTD.ts b/src/fetchMOTD.ts index 51f55b4bc18..6332c2b1e04 100644 --- a/src/fetchMOTD.ts +++ b/src/fetchMOTD.ts @@ -3,6 +3,7 @@ import * as semver from "semver"; import { Client } from "./apiv2"; import { configstore } from "./configstore"; +import { logger } from "./logger"; import { realtimeOrigin } from "./api"; import * as utils from "./utils"; @@ -43,10 +44,15 @@ export function fetchMOTD(): void { } else { const origin = utils.addSubdomain(realtimeOrigin, "firebase-public"); const c = new Client({ urlPrefix: origin, auth: false }); - c.get("/cli.json").then((res) => { - motd = Object.assign({}, res.body); - configstore.set("motd", motd); - configstore.set("motd.fetched", Date.now()); - }); + c.get("/cli.json") + .then((res) => { + motd = Object.assign({}, res.body); + configstore.set("motd", motd); + configstore.set("motd.fetched", Date.now()); + }) + .catch((err) => { + utils.logWarning("Unable to fetch the CLI MOTD and remote config."); + logger.debug(`Failed to fetch MOTD ${err}`); + }); } }