Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow emulators to work offline (MOTD fail) #4998

Merged
merged 6 commits into from Sep 30, 2022

Conversation

ericvera
Copy link
Contributor

Happy to work on the design/messaging as this is occasionally blocking development due to power outages here in Puerto Rico.

Description

This change improve the offline experience for the CLI and unblocks usage of the emulator while offline.

As seen in bug #3916 when offline for more than a day since the last CLI usage, the CLI will attempt to download a MOTD from (https://firebase-public.firebaseio.com/cli.json). If it fails, it just shows an error about failing to fetch the URL.

With this change in the case of emulators:* commands the CLI will print a warning, but continue the execution. In the case of other commands it will print a more descriptive message (see sample outputs below).

Scenarios Tested

Tested running different commands both while online and while offline.

Sample Commands

firebase emulators:start --only auth,functions,firestore

Before:

eric@macbook sample-dir % firebase emulators:start --only auth,functions,firestore
⚠  emulators: You are not currently authenticated so some features may not work correctly. Please run firebase login to authenticate the CLI.

Error: Failed to make request to https://firebase-public.firebaseio.com/cli.json
i  emulators: Starting emulators: auth, functions, firestore
i  emulators: Shutting down emulators.

Error: No currently active project.
To run this command, you need to specify a project. You have two options:
- Run this command with --project <alias_or_project_id>.
- Set an active project by running firebase use --add, then rerun this command.
To list all the Firebase projects to which you have access, run firebase projects:list.
To learn about active projects for the CLI, visit https://firebase.google.com/docs/cli#project_aliases



Having trouble? Try firebase [command] --help

After: (new second emulators warning)

eric@macbook sample-dir % firebase emulators:start --only auth,functions,firestore
⚠  emulators: You are not currently authenticated so some features may not work correctly. Please run firebase login to authenticate the CLI.
⚠  emulators: Unable to fetch the CLI version check configuration, emulator functionality may be incorrect.
i  emulators: Starting emulators: auth, functions, firestore
[...emulators output successfull]

firebase login

Before:

eric@macbook sample-dir % firebase login                                          
i  Firebase optionally collects CLI and Emulator Suite usage and error reporting information to help improve our products. Data is collected in accordance with Google's privacy policy (https://policies.google.com/privacy) and is not used to identify you.

? Allow Firebase to collect CLI and Emulator Suite usage and error reporting information? (Y/n) 
Error: Failed to make request to https://firebase-public.firebaseio.com/cli.json

Having trouble? Try firebase [command] --help

After: (new error that explains how to get past the error)

eric@macbook sample-dir % firebase login
i  Firebase optionally collects CLI and Emulator Suite usage and error reporting information to help improve our products. Data is collected in accordance with Google's privacy policy (https://policies.google.com/privacy) and is not used to identify you.

? Allow Firebase to collect CLI and Emulator Suite usage and error reporting information? (Y/n) 
Error: Unable to fetch the CLI version check configuration. Make sure that you are online and try again.

Having trouble? Try firebase [command] --help

Copy link
Contributor

@bkendall bkendall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a CHANGELOG entry that says:

- Catches errors when fetching CLI MOTD, allowing process to continue.

src/fetchMOTD.ts Outdated Show resolved Hide resolved
@bkendall bkendall self-assigned this Sep 27, 2022
@ericvera
Copy link
Contributor Author

Add a CHANGELOG entry that says:

- Catches errors when fetching CLI MOTD, allowing process to continue.

Added it to the latest changes.

@ericvera ericvera closed this Sep 28, 2022
@ericvera
Copy link
Contributor Author

Accidentally closed the pull request.

@ericvera ericvera reopened this Sep 28, 2022
@ericvera
Copy link
Contributor Author

Re-ran local tests and a sample of commands (emulator and otherwise). They seem to all either proceed (e.g. emulators unless the .tar has not been downloaded yet) or exit gracefully when offline (e.g. functions:* commands).

@bkendall bkendall merged commit 3b4d850 into firebase:master Sep 30, 2022
christhompsongoogle pushed a commit that referenced this pull request Sep 30, 2022
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants