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
@@ -0,0 +1 @@
- Fixes extra logging and race conditions when disabling emulated background functions.
6 changes: 4 additions & 2 deletions src/emulator/functionsEmulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -876,9 +876,9 @@ export class FunctionsEmulator implements EmulatorInstance {
return this.workerPool.submitWork(frb.triggerId, frb, opts);
}

disableBackgroundTriggers() {
async disableBackgroundTriggers() {
Object.values(this.triggers).forEach((record) => {
if (record.def.eventTrigger) {
if (record.def.eventTrigger && record.enabled) {
this.logger.logLabeled(
"BULLET",
`functions[${record.def.entryPoint}]`,
Expand All @@ -887,6 +887,8 @@ export class FunctionsEmulator implements EmulatorInstance {
record.enabled = false;
}
});

await this.workQueue.flush();
}

async reloadTriggers() {
Expand Down
4 changes: 2 additions & 2 deletions src/emulator/hub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export class EmulatorHub implements EmulatorInstance {
}
});

this.hub.put(EmulatorHub.PATH_DISABLE_FUNCTIONS, (req, res) => {
this.hub.put(EmulatorHub.PATH_DISABLE_FUNCTIONS, async (req, res) => {
utils.logLabeledBullet(
"emulators",
`Disabling Cloud Functions triggers, non-HTTP functions will not execute.`
Expand All @@ -117,7 +117,7 @@ export class EmulatorHub implements EmulatorInstance {
}

const emu = instance as FunctionsEmulator;
emu.disableBackgroundTriggers();
await emu.disableBackgroundTriggers();
res.status(200).json({ enabled: false });
});

Expand Down