@@ -20,19 +20,21 @@ import * as request from 'request';
2020import { base64 } from '@firebase/util' ;
2121import { setLogLevel , LogLevel } from '@firebase/logger' ;
2222import * as grpc from 'grpc' ;
23+ import * as protoLoader from '@grpc/proto-loader' ;
2324import { resolve } from 'path' ;
24- import * as fs from 'fs' ;
2525
2626export { database , firestore } from 'firebase' ;
2727
28- const PROTO_ROOT = {
29- root : resolve (
30- __dirname ,
31- process . env . FIRESTORE_EMULATOR_PROTO_ROOT || '../protos'
32- ) ,
33- file : 'google/firestore/emulator/v1/firestore_emulator.proto'
34- } ;
35- const PROTOS = grpc . load ( PROTO_ROOT , /* format = */ 'proto' ) ;
28+ const PROTO_ROOT = resolve (
29+ __dirname ,
30+ process . env . FIRESTORE_EMULATOR_PROTO_ROOT || '../protos'
31+ ) ;
32+ const PROTO_FILE = resolve (
33+ PROTO_ROOT ,
34+ 'google/firestore/emulator/v1/firestore_emulator.proto'
35+ ) ;
36+ const PKG_DEF = protoLoader . loadSync ( PROTO_FILE , { includeDirs : [ PROTO_ROOT ] } ) ;
37+ const PROTOS = grpc . loadPackageDefinition ( PKG_DEF ) ;
3638const EMULATOR = PROTOS [ 'google' ] [ 'firestore' ] [ 'emulator' ] [ 'v1' ] ;
3739
3840/** If this environment variable is set, use it for the database emulator's address. */
@@ -202,13 +204,7 @@ export function loadFirestoreRules(
202204
203205 let client = new EMULATOR . FirestoreEmulator (
204206 FIRESTORE_ADDRESS ,
205- grpc . credentials . createInsecure ( ) ,
206- {
207- // Cap how much backoff gRPC will perform. This is testing code, so
208- // efficiency is less important than responsiveness.
209- 'grpc.initial_reconnect_backoff_ms' : 100 ,
210- 'grpc.max_reconnect_backoff_ms' : 100
211- }
207+ grpc . credentials . createInsecure ( )
212208 ) ;
213209 return new Promise ( ( resolve , reject ) => {
214210 client . setSecurityRules (
0 commit comments