diff --git a/CHANGELOG.md b/CHANGELOG.md index 05704392c7c..73005234f33 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,3 +5,4 @@ - Fixes import/export bug with Storage emulator download tokens (#3414) - Improves errors when failing to start Storage emulator (#3443) - Fixes missing download tokens in Storage Emulator (#3451) +- Fixes `functions:shell` error with background functions (#3490) diff --git a/src/emulator/functionsEmulatorShell.ts b/src/emulator/functionsEmulatorShell.ts index 9ab4559cdb4..c69009b78df 100644 --- a/src/emulator/functionsEmulatorShell.ts +++ b/src/emulator/functionsEmulatorShell.ts @@ -35,13 +35,13 @@ export class FunctionsEmulatorShell implements FunctionsShellController { } } - call(id: string, data: any, opts: any): void { - const trigger = this.getTrigger(id); - logger.debug(`shell:${id}: trigger=${JSON.stringify(trigger)}`); - logger.debug(`shell:${id}: opts=${JSON.stringify(opts)}, data=${JSON.stringify(data)}`); + call(name: string, data: any, opts: any): void { + const trigger = this.getTrigger(name); + logger.debug(`shell:${name}: trigger=${JSON.stringify(trigger)}`); + logger.debug(`shell:${name}: opts=${JSON.stringify(opts)}, data=${JSON.stringify(data)}`); if (!trigger.eventTrigger) { - throw new FirebaseError(`Function ${id} is not a background function`); + throw new FirebaseError(`Function ${name} is not a background function`); } const eventType = trigger.eventTrigger.eventType; @@ -64,16 +64,16 @@ export class FunctionsEmulatorShell implements FunctionsShellController { data, }; - this.emu.startFunctionRuntime(id, trigger.name, EmulatedTriggerType.BACKGROUND, proto); + this.emu.startFunctionRuntime(trigger.id, trigger.name, EmulatedTriggerType.BACKGROUND, proto); } - private getTrigger(id: string): EmulatedTriggerDefinition { + private getTrigger(name: string): EmulatedTriggerDefinition { const result = this.triggers.find((trigger) => { - return trigger.id === id; + return trigger.name === name; }); if (!result) { - throw new FirebaseError(`Could not find trigger ${id}`); + throw new FirebaseError(`Could not find trigger ${name}`); } return result;