Skip to content

Commit 45be193

Browse files
committed
Merge branch 'master' of github.com:firebase/firebase-js-sdk into markduckworth/or-queries
2 parents 1e33050 + a5d9e10 commit 45be193

File tree

83 files changed

+1772
-849
lines changed

Some content is hidden

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

83 files changed

+1772
-849
lines changed

.changeset/kind-pots-admire.md

Lines changed: 0 additions & 7 deletions
This file was deleted.

.changeset/smart-crabs-warn.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@firebase/database": patch
3+
---
4+
5+
Fix issue with how get results for filtered queries are added to cache.
6+
Fix issue with events not getting propagated to listeners by get.

.github/workflows/check-changeset.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: Check Changeset
22

3-
on: pull_request
3+
on:
4+
pull_request:
5+
branches-ignore:
6+
- release
47

58
env:
69
GITHUB_PULL_REQUEST_HEAD_SHA: ${{ github.event.pull_request.head.sha }}

.github/workflows/test-changed.yml

Lines changed: 55 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,61 @@ name: Test Modified Packages
33
on: pull_request
44

55
jobs:
6-
test:
7-
name: Test Packages With Changed Files
6+
test-chrome:
7+
name: Test Packages With Changed Files in Chrome and Node
88
runs-on: ubuntu-latest
99

1010
steps:
11-
- name: Checkout Repo
12-
uses: actions/checkout@master
13-
with:
14-
# This makes Actions fetch all Git history so run-changed script can diff properly.
15-
fetch-depth: 0
16-
- name: Set up Node (14)
17-
uses: actions/setup-node@v2
18-
with:
19-
node-version: 14.x
20-
- name: install Chrome stable
21-
run: |
22-
sudo apt-get update
23-
sudo apt-get install google-chrome-stable
24-
- name: Bump Node memory limit
25-
run: echo "NODE_OPTIONS=--max_old_space_size=4096" >> $GITHUB_ENV
26-
- name: Test setup and yarn install
27-
run: |
28-
cp config/ci.config.json config/project.json
29-
yarn
30-
- name: build
31-
run: yarn build:changed core
32-
- name: Run tests on changed packages
33-
run: xvfb-run yarn test:changed core
11+
- name: Checkout Repo
12+
uses: actions/checkout@master
13+
with:
14+
# This makes Actions fetch all Git history so run-changed script can diff properly.
15+
fetch-depth: 0
16+
- name: Set up Node (14)
17+
uses: actions/setup-node@v2
18+
with:
19+
node-version: 14.x
20+
- name: install Chrome stable
21+
run: |
22+
sudo apt-get update
23+
sudo apt-get install google-chrome-stable
24+
- name: Bump Node memory limit
25+
run: echo "NODE_OPTIONS=--max_old_space_size=4096" >> $GITHUB_ENV
26+
- name: Test setup and yarn install
27+
run: |
28+
cp config/ci.config.json config/project.json
29+
yarn
30+
- name: build
31+
run: yarn build:changed core
32+
- name: Run tests on changed packages
33+
run: xvfb-run yarn test:changed core
34+
35+
test-firefox:
36+
name: Test Packages With Changed Files in Firefox
37+
runs-on: ubuntu-latest
38+
39+
steps:
40+
- name: Checkout Repo
41+
uses: actions/checkout@master
42+
with:
43+
fetch-depth: 0
44+
- name: Set up Node (14)
45+
uses: actions/setup-node@v2
46+
with:
47+
node-version: 14.x
48+
- name: install Firefox stable
49+
run: |
50+
sudo apt-get update
51+
sudo apt-get install firefox
52+
- name: Bump Node memory limit
53+
run: echo "NODE_OPTIONS=--max_old_space_size=4096" >> $GITHUB_ENV
54+
- name: Test setup and yarn install
55+
run: |
56+
cp config/ci.config.json config/project.json
57+
yarn
58+
- name: build
59+
run: yarn build:changed core
60+
- name: Run tests on changed packages
61+
run: xvfb-run yarn test:changed core
62+
env:
63+
BROWSERS: 'Firefox'

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,5 @@ tsdoc-metadata.json
9393

9494
# generated html docs
9595
docs-*/
96-
docs/
96+
docs/
97+
toc/

config/karma.base.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const config = {
6060
// start these browsers
6161
// available browser launchers:
6262
// https://npmjs.org/browse/keyword/karma-launcher
63-
browsers: ['ChromeHeadless'],
63+
browsers: process.env?.BROWSERS?.split(',') ?? ['ChromeHeadless'],
6464

6565
webpack: webpackTestConfig,
6666

integration/compat-interop/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"test:debug": "karma start --browsers Chrome --auto-watch"
99
},
1010
"dependencies": {
11-
"@firebase/app": "0.7.29",
12-
"@firebase/app-compat": "0.1.30",
11+
"@firebase/app": "0.7.30",
12+
"@firebase/app-compat": "0.1.31",
1313
"@firebase/analytics": "0.8.0",
1414
"@firebase/analytics-compat": "0.1.13",
1515
"@firebase/auth": "0.20.5",

integration/firebase/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"test:ci": "node ../../scripts/run_tests_in_ci.js -s test"
88
},
99
"devDependencies": {
10-
"firebase": "9.9.1",
10+
"firebase": "9.9.2",
1111
"@types/chai": "4.3.1",
1212
"@types/mocha": "9.1.1",
1313
"chai": "4.3.6",

integration/firestore/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
"test:memory:debug": "yarn build:memory; karma start --auto-watch --browsers Chrome"
1616
},
1717
"dependencies": {
18-
"@firebase/app": "0.7.29",
19-
"@firebase/firestore": "3.4.13"
18+
"@firebase/app": "0.7.30",
19+
"@firebase/firestore": "3.4.14"
2020
},
2121
"devDependencies": {
2222
"@types/mocha": "9.1.1",

integration/messaging/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"test:manual": "mocha --exit"
1010
},
1111
"devDependencies": {
12-
"firebase": "9.9.1",
12+
"firebase": "9.9.2",
1313
"chai": "4.3.6",
1414
"chromedriver": "98.0.1",
1515
"express": "4.18.1",

packages/analytics-compat/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"@firebase/app-compat": "0.x"
2525
},
2626
"devDependencies": {
27-
"@firebase/app-compat": "0.1.30",
27+
"@firebase/app-compat": "0.1.31",
2828
"rollup": "2.72.1",
2929
"@rollup/plugin-json": "4.1.0",
3030
"rollup-plugin-typescript2": "0.31.2",

packages/analytics/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
},
4949
"license": "Apache-2.0",
5050
"devDependencies": {
51-
"@firebase/app": "0.7.29",
51+
"@firebase/app": "0.7.30",
5252
"rollup": "2.72.1",
5353
"@rollup/plugin-commonjs": "21.1.0",
5454
"@rollup/plugin-json": "4.1.0",

packages/app-check-compat/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
},
4545
"license": "Apache-2.0",
4646
"devDependencies": {
47-
"@firebase/app-compat": "0.1.30",
47+
"@firebase/app-compat": "0.1.31",
4848
"rollup": "2.72.1",
4949
"@rollup/plugin-commonjs": "21.1.0",
5050
"@rollup/plugin-json": "4.1.0",

packages/app-check/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
},
4646
"license": "Apache-2.0",
4747
"devDependencies": {
48-
"@firebase/app": "0.7.29",
48+
"@firebase/app": "0.7.30",
4949
"rollup": "2.72.1",
5050
"@rollup/plugin-commonjs": "21.1.0",
5151
"@rollup/plugin-json": "4.1.0",

packages/app-compat/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# @firebase/app-compat
22

3+
## 0.1.31
4+
5+
### Patch Changes
6+
7+
- Updated dependencies [[`82a6add13`](https://github.com/firebase/firebase-js-sdk/commit/82a6add1354fe7e4ac1d444157ac027cdd41da6e)]:
8+
- @firebase/app@0.7.30
9+
310
## 0.1.30
411

512
### Patch Changes

packages/app-compat/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@firebase/app-compat",
3-
"version": "0.1.30",
3+
"version": "0.1.31",
44
"description": "The primary entrypoint to the Firebase JS SDK",
55
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
66
"main": "dist/index.cjs.js",
@@ -40,7 +40,7 @@
4040
},
4141
"license": "Apache-2.0",
4242
"dependencies": {
43-
"@firebase/app": "0.7.29",
43+
"@firebase/app": "0.7.30",
4444
"@firebase/util": "1.6.3",
4545
"@firebase/logger": "0.3.3",
4646
"@firebase/component": "0.5.17",

packages/app/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @firebase/app
22

3+
## 0.7.30
4+
5+
### Patch Changes
6+
7+
- [`82a6add13`](https://github.com/firebase/firebase-js-sdk/commit/82a6add1354fe7e4ac1d444157ac027cdd41da6e) [#6480](https://github.com/firebase/firebase-js-sdk/pull/6480) - Prevent core app from throwing if IndexedDB heartbeat functions throw.
8+
39
## 0.7.29
410

511
### Patch Changes

packages/app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@firebase/app",
3-
"version": "0.7.29",
3+
"version": "0.7.30",
44
"description": "The primary entrypoint to the Firebase JS SDK",
55
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
66
"main": "dist/index.cjs.js",

packages/app/src/errors.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ export const enum AppError {
2424
APP_DELETED = 'app-deleted',
2525
INVALID_APP_ARGUMENT = 'invalid-app-argument',
2626
INVALID_LOG_ARGUMENT = 'invalid-log-argument',
27-
STORAGE_OPEN = 'storage-open',
28-
STORAGE_GET = 'storage-get',
29-
STORAGE_WRITE = 'storage-set',
30-
STORAGE_DELETE = 'storage-delete'
27+
IDB_OPEN = 'idb-open',
28+
IDB_GET = 'idb-get',
29+
IDB_WRITE = 'idb-set',
30+
IDB_DELETE = 'idb-delete'
3131
}
3232

3333
const ERRORS: ErrorMap<AppError> = {
@@ -43,14 +43,14 @@ const ERRORS: ErrorMap<AppError> = {
4343
'Firebase App instance.',
4444
[AppError.INVALID_LOG_ARGUMENT]:
4545
'First argument to `onLog` must be null or a function.',
46-
[AppError.STORAGE_OPEN]:
47-
'Error thrown when opening storage. Original error: {$originalErrorMessage}.',
48-
[AppError.STORAGE_GET]:
49-
'Error thrown when reading from storage. Original error: {$originalErrorMessage}.',
50-
[AppError.STORAGE_WRITE]:
51-
'Error thrown when writing to storage. Original error: {$originalErrorMessage}.',
52-
[AppError.STORAGE_DELETE]:
53-
'Error thrown when deleting from storage. Original error: {$originalErrorMessage}.'
46+
[AppError.IDB_OPEN]:
47+
'Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.',
48+
[AppError.IDB_GET]:
49+
'Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.',
50+
[AppError.IDB_WRITE]:
51+
'Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.',
52+
[AppError.IDB_DELETE]:
53+
'Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.'
5454
};
5555

5656
interface ErrorParams {
@@ -59,10 +59,10 @@ interface ErrorParams {
5959
[AppError.DUPLICATE_APP]: { appName: string };
6060
[AppError.APP_DELETED]: { appName: string };
6161
[AppError.INVALID_APP_ARGUMENT]: { appName: string };
62-
[AppError.STORAGE_OPEN]: { originalErrorMessage?: string };
63-
[AppError.STORAGE_GET]: { originalErrorMessage?: string };
64-
[AppError.STORAGE_WRITE]: { originalErrorMessage?: string };
65-
[AppError.STORAGE_DELETE]: { originalErrorMessage?: string };
62+
[AppError.IDB_OPEN]: { originalErrorMessage?: string };
63+
[AppError.IDB_GET]: { originalErrorMessage?: string };
64+
[AppError.IDB_WRITE]: { originalErrorMessage?: string };
65+
[AppError.IDB_DELETE]: { originalErrorMessage?: string };
6666
}
6767

6868
export const ERROR_FACTORY = new ErrorFactory<AppError, ErrorParams>(

packages/app/src/indexeddb.test.ts

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/**
2+
* @license
3+
* Copyright 2022 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
import { expect } from 'chai';
19+
import '../test/setup';
20+
import { match, stub } from 'sinon';
21+
import {
22+
readHeartbeatsFromIndexedDB,
23+
writeHeartbeatsToIndexedDB
24+
} from './indexeddb';
25+
import { FirebaseApp } from './public-types';
26+
import { AppError } from './errors';
27+
import { HeartbeatsInIndexedDB } from './types';
28+
29+
/**
30+
* Mostly testing failure cases. heartbeatService.test.ts tests read-write
31+
* more extensively.
32+
*/
33+
34+
describe('IndexedDB functions', () => {
35+
it('readHeartbeatsFromIndexedDB warns if IndexedDB.open() throws', async () => {
36+
const warnStub = stub(console, 'warn');
37+
if (typeof window !== 'undefined') {
38+
// Ensure that indexedDB.open() fails in browser. It will always fail in Node.
39+
stub(window.indexedDB, 'open').throws(new Error('abcd'));
40+
await readHeartbeatsFromIndexedDB({
41+
name: 'testname',
42+
options: { appId: 'test-app-id' }
43+
} as FirebaseApp);
44+
expect(warnStub).to.be.calledWith(match.any, match(AppError.IDB_GET));
45+
} else {
46+
await readHeartbeatsFromIndexedDB({
47+
name: 'testname',
48+
options: { appId: 'test-app-id' }
49+
} as FirebaseApp);
50+
expect(warnStub).to.be.calledWith(match.any, match(AppError.IDB_GET));
51+
}
52+
});
53+
it('writeHeartbeatsToIndexedDB warns if IndexedDB.open() throws', async () => {
54+
const warnStub = stub(console, 'warn');
55+
if (typeof window !== 'undefined') {
56+
// Ensure that indexedDB.open() fails in browser. It will always fail in Node.
57+
stub(window.indexedDB, 'open').throws(new Error('abcd'));
58+
await writeHeartbeatsToIndexedDB(
59+
{
60+
name: 'testname',
61+
options: { appId: 'test-app-id' }
62+
} as FirebaseApp,
63+
{} as HeartbeatsInIndexedDB
64+
);
65+
expect(warnStub).to.be.calledWith(match.any, match(AppError.IDB_WRITE));
66+
} else {
67+
await writeHeartbeatsToIndexedDB(
68+
{
69+
name: 'testname',
70+
options: { appId: 'test-app-id' }
71+
} as FirebaseApp,
72+
{} as HeartbeatsInIndexedDB
73+
);
74+
expect(warnStub).to.be.calledWith(match.any, match(AppError.IDB_WRITE));
75+
}
76+
});
77+
});

0 commit comments

Comments
 (0)