Skip to content

Commit 2a6ad8c

Browse files
author
Brian Chen
authored
Add warning when developer overrides host without specifying merge (#4925)
1 parent 997040a commit 2a6ad8c

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

packages/firestore/src/api/database.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ import {
117117
validateIsNotUsedTogether,
118118
validateSetOptions
119119
} from '../util/input_validation';
120-
import { setLogLevel as setClientLogLevel } from '../util/log';
120+
import { logWarn, setLogLevel as setClientLogLevel } from '../util/log';
121121

122122
import { Blob } from './blob';
123123
import {
@@ -216,14 +216,26 @@ export class Firestore
216216
}
217217

218218
settings(settingsLiteral: PublicSettings): void {
219+
const currentSettings = this._delegate._getSettings();
220+
if (
221+
!settingsLiteral.merge &&
222+
currentSettings.host !== settingsLiteral.host
223+
) {
224+
logWarn(
225+
'You are overriding the original host. If you did not intend ' +
226+
'to override your settings, use {merge: true}.'
227+
);
228+
}
229+
219230
if (settingsLiteral.merge) {
220231
settingsLiteral = {
221-
...this._delegate._getSettings(),
232+
...currentSettings,
222233
...settingsLiteral
223234
};
224235
// Remove the property from the settings once the merge is completed
225236
delete settingsLiteral.merge;
226237
}
238+
227239
this._delegate._setSettings(settingsLiteral);
228240
}
229241

0 commit comments

Comments
 (0)