File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
packages/auth/src/core/auth Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -69,13 +69,27 @@ export function connectAuthEmulator(
69
69
options : Object . freeze ( { disableWarnings } )
70
70
} ) ;
71
71
72
+ // There are a few scenarios to guard against if the Auth instance has already started:
72
73
if ( ! authInternal . _canInitEmulator ) {
74
+ // Applications may not initialize the emulator for the first time if Auth has already started
75
+ // to make network requests.
73
76
_assert (
74
- deepEqual ( emulator , authInternal . config . emulator || { } ) &&
75
- deepEqual ( emulatorConfig , authInternal . emulatorConfig || { } ) ,
77
+ authInternal . config . emulator && authInternal . emulatorConfig ,
76
78
authInternal ,
77
79
AuthErrorCode . EMULATOR_CONFIG_FAILED
78
80
) ;
81
+
82
+ // Applications may not alter the configuration of the emulator (aka pass a different config)
83
+ // once Auth has started to make network requests.
84
+ _assert (
85
+ deepEqual ( emulator , authInternal . config . emulator ) &&
86
+ deepEqual ( emulatorConfig , authInternal . emulatorConfig ) ,
87
+ authInternal ,
88
+ AuthErrorCode . EMULATOR_CONFIG_FAILED
89
+ ) ;
90
+
91
+ // It's valid, however, to invoke connectAuthEmulator() after Auth has started making
92
+ // connections, so long as the config matches the existing config. This results in a no-op.
79
93
return ;
80
94
}
81
95
You can’t perform that action at this time.
0 commit comments