Skip to content
New issue

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

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

Already on GitHub? # to your account

Emulators:exec should rethrow errors from emulator startup #7976

Merged
merged 3 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
- Fixes an issue where `emulators:exec` would return a 0 error code when emulators failed to start. (#7974)
- Added `--import` and `emulators:export` support to the Data Connect emulator.
- Added `firebase.json#emulators.dataconnect.dataDir`. When set, Data Connect data will be persisted to the configured directory between emulator runs.
3 changes: 2 additions & 1 deletion src/emulator/commandUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import * as fsutils from "../fsutils";
import Signals = NodeJS.Signals;
import SignalsListener = NodeJS.SignalsListener;
const Table = require("cli-table");

Check warning on line 20 in src/emulator/commandUtils.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value

Check warning on line 20 in src/emulator/commandUtils.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Require statement not part of import statement
import { emulatorSession } from "../track";
import { setEnvVarsForEmulators } from "./env";
import { sendVSCodeMessage, VSCODE_MESSAGE } from "../dataconnect/webhook";
Expand Down Expand Up @@ -82,7 +82,7 @@
* specify an emulator address.
*/
export function printNoticeIfEmulated(
options: any,

Check warning on line 85 in src/emulator/commandUtils.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
emulator: Emulators.DATABASE | Emulators.FIRESTORE,
): void {
if (emulator !== Emulators.DATABASE && emulator !== Emulators.FIRESTORE) {
Expand Down Expand Up @@ -110,7 +110,7 @@
* an emulator port that the command actually talks to production.
*/
export function warnEmulatorNotSupported(
options: any,

Check warning on line 113 in src/emulator/commandUtils.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
emulator: Emulators.DATABASE | Emulators.FIRESTORE,
): void | Promise<void> {
if (emulator !== Emulators.DATABASE && emulator !== Emulators.FIRESTORE) {
Expand Down Expand Up @@ -150,17 +150,17 @@
* Utility method to be inserted in the "before" function for a command that
* uses the emulator suite.
*/
export async function beforeEmulatorCommand(options: any): Promise<any> {

Check warning on line 153 in src/emulator/commandUtils.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type

Check warning on line 153 in src/emulator/commandUtils.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
const optionsWithDefaultConfig = {

Check warning on line 154 in src/emulator/commandUtils.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value
...options,
config: DEFAULT_CONFIG,
};
const optionsWithConfig = options.config ? options : optionsWithDefaultConfig;

Check warning on line 158 in src/emulator/commandUtils.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value

Check warning on line 158 in src/emulator/commandUtils.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .config on an `any` value

// We want to be able to run most emulators even in the absence of
// firebase.json. For Functions and Hosting we require the JSON file since the
// config interactions can become fairly complex.
const canStartWithoutConfig =

Check warning on line 163 in src/emulator/commandUtils.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value
options.only &&
!controller.shouldStart(optionsWithConfig, Emulators.FUNCTIONS) &&
!controller.shouldStart(optionsWithConfig, Emulators.HOSTING);
Expand Down Expand Up @@ -468,8 +468,9 @@
await sendVSCodeMessage({ message: VSCODE_MESSAGE.EMULATORS_STARTED });
exitCode = await runScript(script, extraEnv);
await controller.onExit(options);
} catch {
} catch (err: unknown) {
await sendVSCodeMessage({ message: VSCODE_MESSAGE.EMULATORS_START_ERRORED });
throw err;
} finally {
await controller.cleanShutdown();
}
Expand Down
Loading