Skip to content
Merged
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- Fixed an issue where the emulator would fail to start when using `firebase-functions` v7+ (#9401).
- Added `functions.list_functions` as a MCP tool (#9369)
- Added AI Logic to `firebase init` CLI command and `firebase_init` MCP tool. (#9185)
- Improved error messages for Firebase AI Logic provisioning during 'firebase init' (#9377)
10 changes: 10 additions & 0 deletions src/emulator/functionsEmulatorRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
rawBody: Buffer;
}

let functionModule: any;

Check warning on line 26 in src/emulator/functionsEmulatorRuntime.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
let FUNCTION_TARGET_NAME: string;
let FUNCTION_SIGNATURE: string;
let FUNCTION_DEBUG_MODE: string;
Expand All @@ -48,7 +48,7 @@
return new Promise((res, rej) => {
try {
res(require(require.resolve(moduleName, opts))); // eslint-disable-line @typescript-eslint/no-var-requires
} catch (e: any) {

Check warning on line 51 in src/emulator/functionsEmulatorRuntime.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
rej(e);
}
});
Expand All @@ -58,7 +58,7 @@
return new Promise((res, rej) => {
try {
res(require.resolve(moduleName, opts));
} catch (e: any) {

Check warning on line 61 in src/emulator/functionsEmulatorRuntime.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
rej(e);
}
});
Expand Down Expand Up @@ -105,22 +105,22 @@
/**
* Gets a property from the original object.
*/
static getOriginal(target: any, key: string): any {

Check warning on line 108 in src/emulator/functionsEmulatorRuntime.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type

Check warning on line 108 in src/emulator/functionsEmulatorRuntime.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
const value = target[key];

Check warning on line 109 in src/emulator/functionsEmulatorRuntime.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access [key] on an `any` value

Check warning on line 109 in src/emulator/functionsEmulatorRuntime.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value

if (!Proxied.isExists(value)) {
return undefined;
} else if (Proxied.isConstructor(value) || typeof value !== "function") {
return value;
} else {
return value.bind(target);

Check warning on line 116 in src/emulator/functionsEmulatorRuntime.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe call of an `any` typed value

Check warning on line 116 in src/emulator/functionsEmulatorRuntime.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .bind on an `any` value
}
}

/**
* Run the original target.
*/
static applyOriginal(target: any, thisArg: any, argArray: any[]): any {

Check warning on line 123 in src/emulator/functionsEmulatorRuntime.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
return target.apply(thisArg, argArray);
}

Expand Down Expand Up @@ -400,6 +400,11 @@
*/
async function initializeFirebaseFunctionsStubs(): Promise<void> {
const firebaseFunctionsResolution = await assertResolveDeveloperNodeModule("firebase-functions");
if (compareVersionStrings(firebaseFunctionsResolution.version, "7.0.0") >= 0) {
logDebug("Detected firebase-functions v7+, skipping legacy stubs.");
return;
}

const firebaseFunctionsRoot = findModuleRoot(
"firebase-functions",
firebaseFunctionsResolution.resolution,
Expand Down Expand Up @@ -711,6 +716,11 @@

async function initializeFunctionsConfigHelper(): Promise<void> {
const functionsResolution = await assertResolveDeveloperNodeModule("firebase-functions");
if (compareVersionStrings(functionsResolution.version, "7.0.0") >= 0) {
logDebug("Detected firebase-functions v7+, skipping config helper.");
return;
}

const localFunctionsModule = require(functionsResolution.resolution);

logDebug("Checked functions.config()", {
Expand Down
Loading