@@ -20,19 +20,21 @@ import * as request from 'request';
20
20
import { base64 } from '@firebase/util' ;
21
21
import { setLogLevel , LogLevel } from '@firebase/logger' ;
22
22
import * as grpc from 'grpc' ;
23
+ import * as protoLoader from '@grpc/proto-loader' ;
23
24
import { resolve } from 'path' ;
24
- import * as fs from 'fs' ;
25
25
26
26
export { database , firestore } from 'firebase' ;
27
27
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 ) ;
36
38
const EMULATOR = PROTOS [ 'google' ] [ 'firestore' ] [ 'emulator' ] [ 'v1' ] ;
37
39
38
40
/** If this environment variable is set, use it for the database emulator's address. */
@@ -202,13 +204,7 @@ export function loadFirestoreRules(
202
204
203
205
let client = new EMULATOR . FirestoreEmulator (
204
206
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 ( )
212
208
) ;
213
209
return new Promise ( ( resolve , reject ) => {
214
210
client . setSecurityRules (
0 commit comments