Skip to content

Fix for starting FAH emulator when no NPM deps #8624

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

Merged
merged 3 commits into from
May 22, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Fix for missing NPM dependencies
  • Loading branch information
jamesdaniels committed May 19, 2025
commit 0340635b731016c7224c1e55baf5f0df05416228
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Address crash when starting the App Hosting emulator in certain applications (#8624)
2 changes: 1 addition & 1 deletion src/emulator/apphosting/serve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@
}
try {
return await secrets.accessSecretVersion(projectId, secretId, version);
} catch (err: any) {

Check warning on line 101 in src/emulator/apphosting/serve.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
if (err?.original?.code === 403 || err?.original?.context?.response?.statusCode === 403) {

Check warning on line 102 in src/emulator/apphosting/serve.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .original on an `any` value

Check warning on line 102 in src/emulator/apphosting/serve.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .original on an `any` value
logLabeledError(
Emulators.APPHOSTING,
`Permission denied to access secret ${secretId}. Use ` +
Expand All @@ -126,10 +126,10 @@
const apphostingLocalConfig = await getLocalAppHostingConfiguration(backendRoot);
const resolveEnv = Object.entries(apphostingLocalConfig.env).map(async ([key, value]) => [
key,
value.value ? value.value : await loadSecret(projectId, value.secret!),

Check warning on line 129 in src/emulator/apphosting/serve.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Forbidden non-null assertion
]);

const environmentVariablesToInject: NodeJS.ProcessEnv = {

Check warning on line 132 in src/emulator/apphosting/serve.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value
NODE_ENV: process.env.NODE_ENV,
...getEmulatorEnvs(),
...Object.fromEntries(await Promise.all(resolveEnv)),
Expand Down Expand Up @@ -165,9 +165,9 @@
);

// NOTE: Development server should not block main emulator process.
spawnWithCommandString(startCommand, backendRoot, environmentVariablesToInject)

Check warning on line 168 in src/emulator/apphosting/serve.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
.catch((err) => {
logger.logLabeled("ERROR", Emulators.APPHOSTING, `failed to start Dev Server: ${err}`);

Check warning on line 170 in src/emulator/apphosting/serve.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Invalid type "any" of template literal expression
})
.then(() => logger.logLabeled("BULLET", Emulators.APPHOSTING, `Dev Server stopped`));
return;
Expand All @@ -177,9 +177,9 @@
logger.logLabeled("BULLET", Emulators.APPHOSTING, `starting app with: '${detectedStartCommand}'`);

// NOTE: Development server should not block main emulator process.
spawnWithCommandString(detectedStartCommand, backendRoot, environmentVariablesToInject)

Check warning on line 180 in src/emulator/apphosting/serve.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
.catch((err) => {
logger.logLabeled("ERROR", Emulators.APPHOSTING, `failed to start Dev Server: ${err}`);

Check warning on line 182 in src/emulator/apphosting/serve.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Invalid type "any" of template literal expression
})
.then(() => logger.logLabeled("BULLET", Emulators.APPHOSTING, `Dev Server stopped`));
}
Expand Down Expand Up @@ -223,8 +223,8 @@
if (!npmLs.stdout) {
return;
}
const npmLsResults = JSON.parse(npmLs.stdout.toString().trim());

Check warning on line 226 in src/emulator/apphosting/serve.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value
const dependenciesToSearch: Dependency[] = Object.values(npmLsResults.dependencies);
const dependenciesToSearch: Dependency[] = Object.values(npmLsResults.dependencies || {});
const firebaseUtilPaths: string[] = [];
for (const dependency of dependenciesToSearch) {
if (
Expand Down
Loading