File tree Expand file tree Collapse file tree 3 files changed +7
-4
lines changed
Expand file tree Collapse file tree 3 files changed +7
-4
lines changed Original file line number Diff line number Diff line change 1+ - Fixes extra logging and race conditions when disabling emulated background functions.
Original file line number Diff line number Diff line change @@ -876,9 +876,9 @@ export class FunctionsEmulator implements EmulatorInstance {
876876 return this . workerPool . submitWork ( frb . triggerId , frb , opts ) ;
877877 }
878878
879- disableBackgroundTriggers ( ) {
879+ async disableBackgroundTriggers ( ) {
880880 Object . values ( this . triggers ) . forEach ( ( record ) => {
881- if ( record . def . eventTrigger ) {
881+ if ( record . def . eventTrigger && record . enabled ) {
882882 this . logger . logLabeled (
883883 "BULLET" ,
884884 `functions[${ record . def . entryPoint } ]` ,
@@ -887,6 +887,8 @@ export class FunctionsEmulator implements EmulatorInstance {
887887 record . enabled = false ;
888888 }
889889 } ) ;
890+
891+ await this . workQueue . flush ( ) ;
890892 }
891893
892894 async reloadTriggers ( ) {
Original file line number Diff line number Diff line change @@ -104,7 +104,7 @@ export class EmulatorHub implements EmulatorInstance {
104104 }
105105 } ) ;
106106
107- this . hub . put ( EmulatorHub . PATH_DISABLE_FUNCTIONS , ( req , res ) => {
107+ this . hub . put ( EmulatorHub . PATH_DISABLE_FUNCTIONS , async ( req , res ) => {
108108 utils . logLabeledBullet (
109109 "emulators" ,
110110 `Disabling Cloud Functions triggers, non-HTTP functions will not execute.`
@@ -117,7 +117,7 @@ export class EmulatorHub implements EmulatorInstance {
117117 }
118118
119119 const emu = instance as FunctionsEmulator ;
120- emu . disableBackgroundTriggers ( ) ;
120+ await emu . disableBackgroundTriggers ( ) ;
121121 res . status ( 200 ) . json ( { enabled : false } ) ;
122122 } ) ;
123123
You can’t perform that action at this time.
0 commit comments