Skip to content

Wrong path when resolving protofile (datastore) #443

@danielcardeenas

Description

@danielcardeenas

Environment details

  • OS: Windows 10
  • Node.js version: 9.11.1
  • npm version: 6.1.0
  • @google-cloud/datastore version: 2.0.0

Steps to reproduce

  1. Use @google/datastore library (runtime)

At runtime. When trying to use datastore library, next error occurs

UnhandledPromiseRejectionWarning: Error: google/datastore/v1/datastore.proto could not be found in \protos
    at Function.GrpcClient._resolveFile (C:\Users\eduardo.cardenas\projects\manufactalent_api\node_modules\google-gax\build\src\grpc.js:220:15)
    at GrpcClient.loadProto (C:\Users\eduardo.cardenas\projects\manufactalent_api\node_modules\google-gax\build\src\grpc.js:209:39)
    at new DatastoreClient (webpack:///./node_modules/@google-cloud/datastore/src/v1/datastore_client.js?:98:15)

Current code.
COMMON_PROTO_FILES array does not contains string "google/datastore/v1/datastore.proto". Also the contents of the array have strings like "google\type\date.proto" (Notice the backslash instead). Maybe an OS issue?

// grpc.js
GrpcClient._resolveFile = function (protoPath, filename) {
      if (fs.existsSync(path.join(protoPath, filename))) {
          return path.join(protoPath, filename);
      }
      else if (COMMON_PROTO_FILES.indexOf(filename) > -1) {
          return path.join(googleProtoFilesDir, filename);
      }
      throw new Error(filename + ' could not be found in ' + protoPath);
  };

Workaround: use googleProtoFilesDir like "google/datastore/v1/datastore.proto" was there in the array

// grpc.js
GrpcClient._resolveFile = function (protoPath, filename) {
      if (fs.existsSync(path.join(googleProtoFilesDir, filename))) {
          return path.join(googleProtoFilesDir, filename);
      }
      else if (COMMON_PROTO_FILES.indexOf(filename) > -1) {
          return path.join(googleProtoFilesDir, filename);
      }
      throw new Error(filename + ' could not be found in ' + protoPath);
  };

Metadata

Metadata

Labels

🚨This issue needs some love.needs more infoThis issue needs more information from the customer to proceed.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.web

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions