Skip to content

Commit

Permalink
Some UX polish for enabling/disabling functions (#3203)
Browse files Browse the repository at this point in the history
  • Loading branch information
samtstern authored Mar 11, 2021
1 parent 863786a commit 6c03c99
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
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

0 comments on commit 6c03c99

Please sign in to comment.