Skip to content
This repository was archived by the owner on Nov 18, 2025. It is now read-only.

Commit 3539b2c

Browse files
fix: reverting to use grpc.loadObject for now (#301)
* debug output * debug output * add logging to operations_client.ts * use loadObject * no more logging
1 parent 5cca97e commit 3539b2c

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

src/grpc.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -198,20 +198,21 @@ export class GrpcClient {
198198
* @return {Object<string, *>} The gRPC loaded result (the toplevel namespace
199199
* object).
200200
*/
201+
201202
loadProto(protoPath: string, filename: string) {
202-
// This set of @grpc/proto-loader options
203-
// 'closely approximates the existing behavior of grpc.load'
204-
const includeDirs = INCLUDE_DIRS.slice();
205-
includeDirs.unshift(protoPath);
206-
const options = {
207-
keepCase: true,
208-
longs: String,
209-
enums: String,
210-
defaults: true,
211-
oneofs: true,
212-
includeDirs
213-
};
214-
return this.loadFromProto(filename, options);
203+
const resolvedPath = GrpcClient._resolveFile(protoPath, filename);
204+
const retval = this.grpc.loadObject(
205+
protobuf.loadSync(resolvedPath, new GoogleProtoFilesRoot()));
206+
return retval;
207+
}
208+
209+
static _resolveFile(protoPath: string, filename: string) {
210+
if (fs.existsSync(path.join(protoPath, filename))) {
211+
return path.join(protoPath, filename);
212+
} else if (COMMON_PROTO_FILES.indexOf(filename) > -1) {
213+
return path.join(googleProtoFilesDir, filename);
214+
}
215+
throw new Error(filename + ' could not be found in ' + protoPath);
215216
}
216217

217218
metadataBuilder(headers: OutgoingHttpHeaders) {

0 commit comments

Comments
 (0)