Skip to content

Commit 3c9c4d2

Browse files
Merge
2 parents 4ebfb3d + 50de3fb commit 3c9c4d2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1089
-276
lines changed

.github/workflows/health-metrics-test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on: [push, pull_request]
55
jobs:
66
binary-size-test:
77
name: Binary Size
8+
if: github.event_name == 'push' || !(github.event.pull_request.head.repo.fork)
89
runs-on: ubuntu-latest
910
env:
1011
METRICS_SERVICE_URL: ${{ secrets.METRICS_SERVICE_URL }}

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"type": "node",
99
"request": "launch",
1010
"name": "RTDB Unit Tests (Node)",
11-
"program": "${workspaceRoot}/packages/firestore/node_modules/.bin/_mocha",
11+
"program": "${workspaceRoot}/packages/firebase/node_modules/.bin/_mocha",
1212
"cwd": "${workspaceRoot}/packages/database",
1313
"args": [
1414
"test/{,!(browser)/**/}*.test.ts",

integration/browserify/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"test": "karma start --single-run"
88
},
99
"dependencies": {
10-
"firebase": "7.13.0"
10+
"firebase": "7.13.1"
1111
},
1212
"devDependencies": {
1313
"@babel/core": "7.8.7",

integration/firebase-typings/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"test": "tsc"
77
},
88
"dependencies": {
9-
"firebase": "7.13.0"
9+
"firebase": "7.13.1"
1010
},
1111
"devDependencies": {
1212
"typescript": "3.8.3"

integration/messaging/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"test:manual": "mocha --exit"
99
},
1010
"dependencies": {
11-
"firebase": "7.13.0"
11+
"firebase": "7.13.1"
1212
},
1313
"devDependencies": {
1414
"chai": "4.2.0",

integration/typescript/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"test": "karma start --single-run"
77
},
88
"dependencies": {
9-
"firebase": "7.13.0"
9+
"firebase": "7.13.1"
1010
},
1111
"devDependencies": {
1212
"@babel/core": "7.8.7",

integration/webpack/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"test": "karma start --single-run"
88
},
99
"dependencies": {
10-
"firebase": "7.13.0"
10+
"firebase": "7.13.1"
1111
},
1212
"devDependencies": {
1313
"@babel/core": "7.8.7",

packages/database/src/api/Database.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @license
3-
* Copyright 2017 Google Inc.
3+
* Copyright 2017 Google LLC
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
@@ -39,6 +39,13 @@ export class Database implements FirebaseService {
3939
static readonly ServerValue = {
4040
TIMESTAMP: {
4141
'.sv': 'timestamp'
42+
},
43+
_increment: (x: number) => {
44+
return {
45+
'.sv': {
46+
'increment': x
47+
}
48+
};
4249
}
4350
};
4451

packages/database/src/core/Repo.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @license
3-
* Copyright 2017 Google Inc.
3+
* Copyright 2017 Google LLC
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
@@ -313,8 +313,10 @@ export class Repo {
313313
// (b) store unresolved paths on JSON parse
314314
const serverValues = this.generateServerValues();
315315
const newNodeUnresolved = nodeFromJSON(newVal, newPriority);
316+
const existing = this.serverSyncTree_.calcCompleteEventCache(path);
316317
const newNode = resolveDeferredValueSnapshot(
317318
newNodeUnresolved,
319+
existing,
318320
serverValues
319321
);
320322

@@ -362,9 +364,10 @@ export class Repo {
362364
const changedChildren: { [k: string]: Node } = {};
363365
each(childrenToMerge, (changedKey: string, changedValue: unknown) => {
364366
empty = false;
365-
const newNodeUnresolved = nodeFromJSON(changedValue);
366-
changedChildren[changedKey] = resolveDeferredValueSnapshot(
367-
newNodeUnresolved,
367+
changedChildren[changedKey] = resolveDeferredValueTree(
368+
path.child(changedKey),
369+
nodeFromJSON(changedValue),
370+
this.serverSyncTree_,
368371
serverValues
369372
);
370373
});
@@ -417,10 +420,16 @@ export class Repo {
417420
this.log_('onDisconnectEvents');
418421

419422
const serverValues = this.generateServerValues();
420-
const resolvedOnDisconnectTree = resolveDeferredValueTree(
421-
this.onDisconnect_,
422-
serverValues
423-
);
423+
const resolvedOnDisconnectTree = new SparseSnapshotTree();
424+
this.onDisconnect_.forEachTree(Path.Empty, (path, node) => {
425+
const resolved = resolveDeferredValueTree(
426+
path,
427+
node,
428+
this.serverSyncTree_,
429+
serverValues
430+
);
431+
resolvedOnDisconnectTree.remember(path, resolved);
432+
});
424433
let events: Event[] = [];
425434

426435
resolvedOnDisconnectTree.forEachTree(Path.Empty, (path, snap) => {

packages/database/src/core/Repo_transaction.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @license
3-
* Copyright 2017 Google Inc.
3+
* Copyright 2017 Google LLC
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
@@ -248,6 +248,7 @@ Repo.prototype.startTransaction = function(
248248
const newNodeUnresolved = nodeFromJSON(newVal, priorityForNode);
249249
const newNode = resolveDeferredValueSnapshot(
250250
newNodeUnresolved,
251+
currentState,
251252
serverValues
252253
);
253254
transaction.currentOutputSnapshotRaw = newNodeUnresolved;
@@ -533,6 +534,7 @@ Repo.prototype.startTransaction = function(
533534
const serverValues = this.generateServerValues();
534535
const newNodeResolved = resolveDeferredValueSnapshot(
535536
newDataNode,
537+
currentNode,
536538
serverValues
537539
);
538540

packages/database/src/core/SyncTree.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @license
3-
* Copyright 2017 Google Inc.
3+
* Copyright 2017 Google LLC
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
@@ -474,18 +474,17 @@ export class SyncTree {
474474
}
475475

476476
/**
477-
* Returns a complete cache, if we have one, of the data at a particular path. The location must have a listener above
478-
* it, but as this is only used by transaction code, that should always be the case anyways.
477+
* Returns a complete cache, if we have one, of the data at a particular path. If the location does not have a
478+
* listener above it, we will get a false "null". This shouldn't be a problem because transactions will always
479+
* have a listener above, and atomic operations would correctly show a jitter of <increment value> ->
480+
* <incremented total> as the write is applied locally and then acknowledged at the server.
479481
*
480482
* Note: this method will *include* hidden writes from transaction with applyLocally set to false.
481483
*
482484
* @param path The path to the data we want
483485
* @param writeIdsToExclude A specific set to be excluded
484486
*/
485-
calcCompleteEventCache(
486-
path: Path,
487-
writeIdsToExclude?: number[]
488-
): Node | null {
487+
calcCompleteEventCache(path: Path, writeIdsToExclude?: number[]): Node {
489488
const includeHiddenSets = true;
490489
const writeTree = this.pendingWriteTree_;
491490
const serverCache = this.syncPointTree_.findOnPath(

0 commit comments

Comments
 (0)