Skip to content

Commit

Permalink
Allow emulators to work offline (MOTD fail) (#4998)
Browse files Browse the repository at this point in the history
* 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 <bkend@google.com>
  • Loading branch information
ericvera and bkendall committed Sep 30, 2022
1 parent 4184ad7 commit 3b4d850
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions 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).
16 changes: 11 additions & 5 deletions src/fetchMOTD.ts
Expand Up @@ -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";

Expand Down Expand Up @@ -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}`);
});
}
}

0 comments on commit 3b4d850

Please sign in to comment.