Skip to content
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
Expand Up @@ -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)
18 changes: 9 additions & 9 deletions src/emulator/functionsEmulatorShell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What will happen if this finds 2 functions? (aka, it's in 2 regions)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it'll run the first one? That seems sketchy but also not sure how to improve it without making people type out the region.

});

if (!result) {
throw new FirebaseError(`Could not find trigger ${id}`);
throw new FirebaseError(`Could not find trigger ${name}`);
}

return result;
Expand Down