Skip to content

Commit df8eaf9

Browse files
fix: improve performance of loadProtoJSON (#1196)
1 parent 45ba7dc commit df8eaf9

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/fallback.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import {
2828
GoogleAuthOptions,
2929
BaseExternalAccountClient,
3030
} from 'google-auth-library';
31-
import * as objectHash from 'object-hash';
3231
import {OperationsClientBuilder} from './operationsClient';
3332
import {GrpcClientOptions, ClientStubOptions} from './grpc';
3433
import {GaxCall, GRPCCall} from './apitypes';
@@ -40,6 +39,7 @@ import * as fallbackRest from './fallbackRest';
4039
import {isNodeJS} from './featureDetection';
4140
import {generateServiceStub} from './fallbackServiceStub';
4241
import {StreamType} from '.';
42+
import * as objectHash from 'object-hash';
4343

4444
export {FallbackServiceError};
4545
export {PathTemplate} from './pathTemplate';
@@ -135,7 +135,7 @@ export class GrpcClient {
135135
}
136136

137137
loadProtoJSON(json: protobuf.INamespace, ignoreCache = false) {
138-
const hash = objectHash(json).toString();
138+
const hash = objectHash(JSON.stringify(json)).toString();
139139
const cached = GrpcClient.protoCache.get(hash);
140140
if (cached && !ignoreCache) {
141141
return cached;

src/grpc.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ export class GrpcClient {
292292
}
293293

294294
loadProtoJSON(json: protobuf.INamespace, ignoreCache = false) {
295-
const hash = objectHash(json).toString();
295+
const hash = objectHash(JSON.stringify(json)).toString();
296296
const cached = GrpcClient.protoCache.get(hash);
297297
if (cached && !ignoreCache) {
298298
return cached;

test/fixtures/google-gax-packaging-test-app/test/gapic-v1beta1.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ describe('v1beta1.EchoClient', () => {
357357
);
358358
});
359359

360-
it.only('invokes echo with closed client', async () => {
360+
it('invokes echo with closed client', async () => {
361361
const client = new echoModule.v1beta1.EchoClient({
362362
credentials: {client_email: 'bogus', private_key: 'bogus'},
363363
projectId: 'bogus',

0 commit comments

Comments
 (0)