Skip to content

Commit

Permalink
Switch from 'grpc' to '@grpc/grpc-js' dependency.
Browse files Browse the repository at this point in the history
Fixes #1783, reduces package size, and should ease compatibility issues with Electron, etc.
  • Loading branch information
Michael Lehenbauer committed May 20, 2019
1 parent 5f5f1c1 commit 80be07b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 23 deletions.
2 changes: 1 addition & 1 deletion packages/firestore/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
"@firebase/firestore-types": "1.3.0",
"@firebase/logger": "0.1.14",
"@firebase/webchannel-wrapper": "0.2.20",
"@grpc/grpc-js": "0.4.0",
"@grpc/proto-loader": "^0.5.0",
"grpc": "1.20.3",
"tslib": "1.9.3"
},
"peerDependencies": {
Expand Down
13 changes: 3 additions & 10 deletions packages/firestore/src/platform_node/grpc_connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
* limitations under the License.
*/

import * as grpc from 'grpc';
import * as grpc from '@grpc/grpc-js';

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

const grpcVersion = require('grpc/package.json').version;
const grpcVersion = require('@grpc/grpc-js/package.json').version;

import { Token } from '../api/credentials';
import { DatabaseInfo } from '../core/database_info';
Expand Down Expand Up @@ -97,14 +97,7 @@ export class GrpcConnection implements Connection {
: grpc.credentials.createInsecure();
this.cachedStub = new this.firestore.Firestore(
this.databaseInfo.host,
credentials,
{
// We do our own connection backoff (that for example is aware of whether or
// not a write stream error is permanent or not) so we don't want gRPC to do
// backoff on top of that. 100ms is the minimum value that gRPC allows.
'grpc.initial_reconnect_backoff_ms': 100,
'grpc.max_reconnect_backoff_ms': 100
}
credentials
);
}
return this.cachedStub;
Expand Down
2 changes: 1 addition & 1 deletion packages/firestore/src/platform_node/load_protos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
* limitations under the License.
*/

import * as grpc from '@grpc/grpc-js';
import * as protoLoader from '@grpc/proto-loader';
import * as grpc from 'grpc';
import * as path from 'path';
import * as ProtobufJS from 'protobufjs';

Expand Down
18 changes: 7 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,13 @@
through2 "^2.0.0"
xdg-basedir "^3.0.0"

"@grpc/[email protected]":
version "0.4.0"
resolved "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-0.4.0.tgz#b20a6abf1346ce7fd696a042f83d10c94e143881"
integrity sha512-UbGDPnstJamJrSiHzCSwSavIX260IfLOZLRJYDqRKJA/jmVZa3hPMWDjhFrcCKDq2MLc/O/nauFED3r4khcZrA==
dependencies:
semver "^6.0.0"

"@grpc/proto-loader@^0.5.0":
version "0.5.0"
resolved "https://registry.npmjs.org/@grpc/proto-loader/-/proto-loader-0.5.0.tgz#6d21930530db6089ed68a90f10a22b76fdc3387d"
Expand Down Expand Up @@ -6901,17 +6908,6 @@ [email protected]:
node-pre-gyp "^0.13.0"
protobufjs "^5.0.3"

[email protected]:
version "1.20.3"
resolved "https://registry.npmjs.org/grpc/-/grpc-1.20.3.tgz#a74d36718f1e89c4a64f2fb9441199c3c8f78978"
integrity sha512-GsEsi0NVj6usS/xor8pF/xDbDiwZQR59aZl5NUZ59Sy2bdPQFZ3UePr5wevZjHboirRCIQCKRI1cCgvSWUe2ag==
dependencies:
lodash.camelcase "^4.3.0"
lodash.clone "^4.5.0"
nan "^2.13.2"
node-pre-gyp "^0.13.0"
protobufjs "^5.0.3"

gtoken@^1.2.1, gtoken@^1.2.3:
version "1.2.3"
resolved "https://registry.npmjs.org/gtoken/-/gtoken-1.2.3.tgz#5509571b8afd4322e124cf66cf68115284c476d8"
Expand Down

0 comments on commit 80be07b

Please sign in to comment.