Skip to content

Commit e0fb73d

Browse files
Drop Node 6 / Replace grpc w/ @grpc/grpc-js
1 parent e062933 commit e0fb73d

File tree

10 files changed

+63
-126
lines changed

10 files changed

+63
-126
lines changed

package.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@
55
"private": true,
66
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
77
"license": "Apache-2.0",
8+
"engines": {
9+
"node": "^8.13.0 || >=10.10.0"
10+
},
811
"homepage": "https://github.com/firebase/firebase-js-sdk",
912
"keywords": [
1013
"authentication",
1114
"database",
1215
"Firebase",
1316
"firebase",
17+
"firestore",
1418
"functions",
1519
"realtime",
1620
"storage",
@@ -55,7 +59,7 @@
5559
"@types/chai-as-promised": "7.1.2",
5660
"@types/long": "4.0.1",
5761
"@types/mocha": "7.0.2",
58-
"@types/node": "8.10.59",
62+
"@types/node": "13.11.0",
5963
"@types/sinon": "7.5.2",
6064
"@types/sinon-chai": "3.2.3",
6165
"@typescript-eslint/eslint-plugin": "2.24.0",

packages/firebase/package.json

+4
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@
55
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
66
"license": "Apache-2.0",
77
"homepage": "https://firebase.google.com/",
8+
"engines": {
9+
"node": "^8.13.0 || >=10.10.0"
10+
},
811
"keywords": [
912
"authentication",
1013
"database",
1114
"Firebase",
1215
"firebase",
16+
"firestore",
1317
"realtime",
1418
"storage",
1519
"performance",

packages/firestore/package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{
22
"name": "@firebase/firestore",
33
"version": "1.13.0",
4+
"engines": {
5+
"node": "^8.13.0 || >=10.10.0"
6+
},
47
"description": "The Cloud Firestore component of the Firebase JS SDK.",
58
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
69
"scripts": {
@@ -41,8 +44,8 @@
4144
"@firebase/logger": "0.2.0",
4245
"@firebase/util": "0.2.43",
4346
"@firebase/webchannel-wrapper": "0.2.38",
47+
"@grpc/grpc-js": "0.7.5",
4448
"@grpc/proto-loader": "^0.5.0",
45-
"grpc": "1.24.2",
4649
"tslib": "1.11.1"
4750
},
4851
"peerDependencies": {

packages/firestore/src/local/local_serializer.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export class LocalSerializer {
170170
mutations
171171
);
172172
}
173-
173+
174174
/** Decodes a DbTarget into TargetData */
175175
fromDbTarget(dbTarget: DbTarget): TargetData {
176176
const version = this.fromDbTimestamp(dbTarget.readTime);

packages/firestore/src/platform_node/grpc_connection.ts

+15-10
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,18 @@
1515
* limitations under the License.
1616
*/
1717

18-
import * as grpc from 'grpc';
18+
import {
19+
Metadata,
20+
GrpcObject,
21+
credentials as GrpcCredentials,
22+
ServiceError
23+
} from '@grpc/grpc-js';
1924

2025
import firebase from '@firebase/app';
2126
const SDK_VERSION = firebase.SDK_VERSION;
2227

2328
// eslint-disable-next-line @typescript-eslint/no-require-imports
24-
const grpcVersion = require('grpc/package.json').version;
29+
const grpcVersion = require('@grpc/grpc-js/package.json').version;
2530

2631
import { Token } from '../api/credentials';
2732
import { DatabaseInfo } from '../core/database_info';
@@ -44,13 +49,13 @@ const X_GOOG_API_CLIENT_VALUE = `gl-node/${process.versions.node} fire/${SDK_VER
4449
function createMetadata(
4550
databaseInfo: DatabaseInfo,
4651
token: Token | null
47-
): grpc.Metadata {
52+
): Metadata {
4853
assert(
4954
token === null || token.type === 'OAuth',
5055
'If provided, token must be OAuth'
5156
);
5257

53-
const metadata = new grpc.Metadata();
58+
const metadata = new Metadata();
5459
if (token) {
5560
for (const header in token.authHeaders) {
5661
if (token.authHeaders.hasOwnProperty(header)) {
@@ -84,7 +89,7 @@ export class GrpcConnection implements Connection {
8489
// We cache stubs for the most-recently-used token.
8590
private cachedStub: GeneratedGrpcStub | null = null;
8691

87-
constructor(protos: grpc.GrpcObject, private databaseInfo: DatabaseInfo) {
92+
constructor(protos: GrpcObject, private databaseInfo: DatabaseInfo) {
8893
// eslint-disable-next-line @typescript-eslint/no-explicit-any
8994
this.firestore = (protos as any)['google']['firestore']['v1'];
9095
}
@@ -93,8 +98,8 @@ export class GrpcConnection implements Connection {
9398
if (!this.cachedStub) {
9499
logDebug(LOG_TAG, 'Creating Firestore stub.');
95100
const credentials = this.databaseInfo.ssl
96-
? grpc.credentials.createSsl()
97-
: grpc.credentials.createInsecure();
101+
? GrpcCredentials.createSsl()
102+
: GrpcCredentials.createInsecure();
98103
this.cachedStub = new this.firestore.Firestore(
99104
this.databaseInfo.host,
100105
credentials
@@ -116,7 +121,7 @@ export class GrpcConnection implements Connection {
116121
return stub[rpcName](
117122
request,
118123
metadata,
119-
(grpcError?: grpc.ServiceError, value?: Resp) => {
124+
(grpcError?: ServiceError, value?: Resp) => {
120125
if (grpcError) {
121126
logDebug(LOG_TAG, `RPC '${rpcName}' failed with error:`, grpcError);
122127
callback(
@@ -162,7 +167,7 @@ export class GrpcConnection implements Connection {
162167
logDebug(LOG_TAG, `RPC '${rpcName}' completed.`);
163168
responseDeferred.resolve(results);
164169
});
165-
stream.on('error', (grpcError: grpc.ServiceError) => {
170+
stream.on('error', (grpcError: ServiceError) => {
166171
logDebug(LOG_TAG, `RPC '${rpcName}' failed with error:`, grpcError);
167172
const code = mapCodeFromRpcCode(grpcError.code);
168173
responseDeferred.reject(new FirestoreError(code, grpcError.message));
@@ -224,7 +229,7 @@ export class GrpcConnection implements Connection {
224229
close();
225230
});
226231

227-
grpcStream.on('error', (grpcError: grpc.ServiceError) => {
232+
grpcStream.on('error', (grpcError: ServiceError) => {
228233
logDebug(
229234
LOG_TAG,
230235
'GRPC stream error. Code:',

packages/firestore/src/platform_node/load_protos.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717

1818
import { loadSync } from '@grpc/proto-loader';
19-
import { loadPackageDefinition, GrpcObject } from 'grpc';
19+
import { loadPackageDefinition, GrpcObject } from '@grpc/grpc-js';
2020
import { join, resolve, isAbsolute } from 'path';
2121
// only used in tests
2222
// eslint-disable-next-line import/no-extraneous-dependencies

packages/firestore/src/util/async_queue.ts

+1
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ class DelayedOperation<T extends unknown> implements CancelablePromise<T> {
168168
readonly [Symbol.toStringTag]: 'Promise';
169169
then = this.deferred.promise.then.bind(this.deferred.promise);
170170
catch = this.deferred.promise.catch.bind(this.deferred.promise);
171+
finally = this.deferred.promise.finally.bind(this.deferred.promise);
171172

172173
private handleDelayElapsed(): void {
173174
this.asyncQueue.enqueueAndForget(() => {

packages/testing/package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
"description": "",
55
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
66
"main": "dist/index.cjs.js",
7+
"engines": {
8+
"node": "^8.13.0 || >=10.10.0"
9+
},
710
"files": [
811
"dist"
912
],
@@ -16,11 +19,10 @@
1619
},
1720
"license": "Apache-2.0",
1821
"dependencies": {
19-
"firebase": "7.13.1",
2022
"@firebase/logger": "0.2.0",
2123
"@firebase/util": "0.2.43",
2224
"@types/request": "2.48.4",
23-
"grpc": "1.24.2",
25+
"firebase": "7.13.1",
2426
"request": "2.88.2"
2527
},
2628
"devDependencies": {

packages/testing/src/api/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { FirebaseAuthInternal } from '@firebase/auth-interop-types';
2121
import * as request from 'request';
2222
import { base64 } from '@firebase/util';
2323
import { setLogLevel, LogLevel } from '@firebase/logger';
24-
import * as grpc from 'grpc';
24+
import * as grpc from '@grpc/grpc-js';
2525
import * as protoLoader from '@grpc/proto-loader';
2626
import { resolve } from 'path';
2727
import { Component, ComponentType } from '@firebase/component';

0 commit comments

Comments
 (0)