Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX-MISSING-FILE: Cannot read property 'ns' of null - when missing proto/json files #227

Closed
cblair opened this issue Mar 16, 2018 · 0 comments

Comments

@cblair
Copy link
Contributor

cblair commented Mar 16, 2018

Problem

When trying to load proto files, if the path is not found, grpc dies in a non-obvious way:

TypeError: Cannot read property 'ns' of null
      at Object.load (node_modules/grpc/index.js:146:28)
      at loadRpcService (node_modules/@communityco/platform-helpers/lib/service/utils/grpc.js:42:22)
      at createRpcClient (node_modules/@communityco/platform-helpers/lib/service/utils/grpc.js:60:19)
      at createClient (node_modules/@communityco/platform-helpers/lib/service/index.js:55:22)
      at Context.before (test/profiles.component.test.js:58:14)

Synopsis

This is due to some fault intolerant code when making an internal builder object:

return loadObject(builder.ns, options);

try {
    switch(format) {
      case 'proto':
      builder = ProtoBuf.loadProtoFile(filename);
      break;
      case 'json':
      builder = ProtoBuf.loadJsonFile(filename);
      break;
      default:
      throw new Error('Unrecognized format "' + format + '"');
    }
  } finally {
    ProtoBuf.convertFieldsToCamelCase = convertFieldsToCamelCaseOriginal;
  }
  return loadObject(builder.ns, options);

Expected Behavior

In the case in which a file cannot be found, throw an exception indicating so.

Simple fix, PR WIP.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 29, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant