Skip to content

Commit 02ca42e

Browse files
committed
Implementation
1 parent 4e6a5c6 commit 02ca42e

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

packages/firestore/src/lite-api/database.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
} from '@firebase/app';
2525
import {
2626
createMockUserToken,
27+
deepEqual,
2728
EmulatorMockTokenOptions,
2829
getDefaultEmulatorHostnameAndPort
2930
} from '@firebase/util';
@@ -324,12 +325,20 @@ export function connectFirestoreEmulator(
324325
'will be used.'
325326
);
326327
}
327-
328-
firestore._setSettings({
328+
const privateSettings = {
329329
...settings,
330330
host: newHostSetting,
331331
ssl: false
332-
});
332+
};
333+
334+
// Turn this invocation into a no-op if the new configuration matches the current configuration.
335+
// This helps support SSR enviornments where `connectFirestoreEmulator` could be called multiple
336+
// times.
337+
if(deepEqual(privateSettings, settings)) {
338+
return;
339+
}
340+
341+
firestore._setSettings(privateSettings);
333342

334343
if (options.mockUserToken) {
335344
let token: string;

0 commit comments

Comments
 (0)