File tree 3 files changed +7
-4
lines changed
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 {
876
876
return this . workerPool . submitWork ( frb . triggerId , frb , opts ) ;
877
877
}
878
878
879
- disableBackgroundTriggers ( ) {
879
+ async disableBackgroundTriggers ( ) {
880
880
Object . values ( this . triggers ) . forEach ( ( record ) => {
881
- if ( record . def . eventTrigger ) {
881
+ if ( record . def . eventTrigger && record . enabled ) {
882
882
this . logger . logLabeled (
883
883
"BULLET" ,
884
884
`functions[${ record . def . entryPoint } ]` ,
@@ -887,6 +887,8 @@ export class FunctionsEmulator implements EmulatorInstance {
887
887
record . enabled = false ;
888
888
}
889
889
} ) ;
890
+
891
+ await this . workQueue . flush ( ) ;
890
892
}
891
893
892
894
async reloadTriggers ( ) {
Original file line number Diff line number Diff line change @@ -104,7 +104,7 @@ export class EmulatorHub implements EmulatorInstance {
104
104
}
105
105
} ) ;
106
106
107
- this . hub . put ( EmulatorHub . PATH_DISABLE_FUNCTIONS , ( req , res ) => {
107
+ this . hub . put ( EmulatorHub . PATH_DISABLE_FUNCTIONS , async ( req , res ) => {
108
108
utils . logLabeledBullet (
109
109
"emulators" ,
110
110
`Disabling Cloud Functions triggers, non-HTTP functions will not execute.`
@@ -117,7 +117,7 @@ export class EmulatorHub implements EmulatorInstance {
117
117
}
118
118
119
119
const emu = instance as FunctionsEmulator ;
120
- emu . disableBackgroundTriggers ( ) ;
120
+ await emu . disableBackgroundTriggers ( ) ;
121
121
res . status ( 200 ) . json ( { enabled : false } ) ;
122
122
} ) ;
123
123
You can’t perform that action at this time.
0 commit comments