From ae956306c9706353372ce65834ee2287c2358299 Mon Sep 17 00:00:00 2001 From: Joe Hanley Date: Wed, 30 Sep 2026 23:32:44 +0000 Subject: [PATCH 1/2] refactor(emulators): remove dead EmulatedTrigger and waitForBody cluster from functionsEmulatorShared (b/568084058) --- src/emulator/functionsEmulatorShared.ts | 75 +------------------------ 1 file changed, 1 insertion(+), 74 deletions(-) diff --git a/src/emulator/functionsEmulatorShared.ts b/src/emulator/functionsEmulatorShared.ts index 99e35e6e90b..b53ae24e718 100644 --- a/src/emulator/functionsEmulatorShared.ts +++ b/src/emulator/functionsEmulatorShared.ts @@ -2,14 +2,10 @@ import * as os from "os"; import * as path from "path"; import * as fs from "fs"; import { randomBytes } from "crypto"; -import * as _ from "lodash"; -import * as express from "express"; -import { CloudFunction } from "firebase-functions"; - import * as backend from "../deploy/functions/backend"; import * as build from "../deploy/functions/build"; import { Constants } from "./constants"; -import { BackendInfo, EmulatableBackend, InvokeRuntimeOpts } from "./functionsEmulator"; +import { BackendInfo, EmulatableBackend } from "./functionsEmulator"; import { ENV_DIRECTORY } from "../extensions/manifest"; import { substituteParams } from "../extensions/extensionsHelper"; import { ExtensionSpec, ExtensionVersion } from "../extensions/types"; @@ -103,14 +99,6 @@ export interface EventTrigger { service?: string; } -export interface EmulatedTriggerMap { - [name: string]: EmulatedTrigger; -} - -export interface FunctionsRuntimeArgs { - frb: FunctionsRuntimeBundle; - opts?: InvokeRuntimeOpts; -} export interface FunctionsRuntimeBundle { proto: any; @@ -131,34 +119,6 @@ export interface FunctionsRuntimeFeatures { timeout?: boolean; } -export class EmulatedTrigger { - /* - Here we create a trigger from a single definition (data about what resources does this trigger on, etc) and - the actual module which contains multiple functions / definitions. We locate the one we need below using - definition.entryPoint - */ - constructor( - public definition: EmulatedTriggerDefinition, - private module: any, - ) {} - - get memoryLimitBytes(): number { - return (this.definition.availableMemoryMb || 128) * 1024 * 1024; - } - - get timeoutMs(): number { - return (this.definition.timeoutSeconds || 60) * 1000; - } - - getRawFunction(): CloudFunction { - if (!this.module) { - throw new Error("EmulatedTrigger has not been provided a module."); - } - - const func = _.get(this.module, this.definition.entryPoint); - return func.__emulator_func || func; - } -} /** * Checks if the v2 event service has been implemented in the emulator @@ -319,24 +279,6 @@ export function emulatedFunctionsByRegion( return regionDefinitions; } -/** - * Converts an array of EmulatedTriggerDefinitions to a map of EmulatedTriggers, which contain information on execution, - * @param {EmulatedTriggerDefinition[]} definitions An array of regionalized, parsed trigger definitions - * @param {object} module Actual module which contains multiple functions / definitions - * @return a map of trigger ids to EmulatedTriggers - */ -export function getEmulatedTriggersFromDefinitions( - definitions: EmulatedTriggerDefinition[], - module: any, // eslint-disable-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -): EmulatedTriggerMap { - return definitions.reduce( - (obj: { [triggerName: string]: EmulatedTrigger }, definition: EmulatedTriggerDefinition) => { - obj[definition.id] = new EmulatedTrigger(definition, module); - return obj; - }, - {}, - ); -} /** * Create a path that used to create a tempfile for IPC over socket files. @@ -429,21 +371,6 @@ export function getServiceFromEventType(eventType: string): string { return ""; } -/** - * Create a Promise which can be awaited to recieve request bodies as strings. - */ -export function waitForBody(req: express.Request): Promise { - let data = ""; - return new Promise((resolve) => { - req.on("data", (chunk: any) => { - data += chunk; - }); - - req.on("end", () => { - resolve(data); - }); - }); -} /** * Find the root directory housing a node module. From cffc080f9b39b802e08354e20d4fac34446b1fa8 Mon Sep 17 00:00:00 2001 From: Joe Hanley Date: Wed, 30 Sep 2026 23:46:08 +0000 Subject: [PATCH 2/2] fix: resolve prettier blank line errors on PR #11213 --- src/emulator/functionsEmulatorShared.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/emulator/functionsEmulatorShared.ts b/src/emulator/functionsEmulatorShared.ts index b53ae24e718..bb5d27d0c03 100644 --- a/src/emulator/functionsEmulatorShared.ts +++ b/src/emulator/functionsEmulatorShared.ts @@ -99,7 +99,6 @@ export interface EventTrigger { service?: string; } - export interface FunctionsRuntimeBundle { proto: any; disabled_features?: FunctionsRuntimeFeatures; @@ -119,7 +118,6 @@ export interface FunctionsRuntimeFeatures { timeout?: boolean; } - /** * Checks if the v2 event service has been implemented in the emulator */ @@ -279,7 +277,6 @@ export function emulatedFunctionsByRegion( return regionDefinitions; } - /** * Create a path that used to create a tempfile for IPC over socket files. */ @@ -371,7 +368,6 @@ export function getServiceFromEventType(eventType: string): string { return ""; } - /** * Find the root directory housing a node module. */