From 3b4d8503ccede2ba3ad9ce868ff6604657995156 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 --- CHANGELOG.md | 1 + src/fetchMOTD.ts | 16 +++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e1ea703cdc8..30cd9bc0d19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,2 +1,3 @@ - Add the "experiments" family of commands (#4994) - Enable detecting and skipping no-op function deploys (#5032). +- Catches errors when fetching CLI MOTD, allowing process to continue (#4998). 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}`); + }); } }