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

Protos which depend on a namespace which contains a type key prevents loading of the services #270

Closed
eeston opened this issue Jul 12, 2021 · 4 comments
Assignees

Comments

@eeston
Copy link
Contributor

eeston commented Jul 12, 2021

Describe the bug
As part of the optimisation work done recently, this line is preventing our services from being loaded and started by Mali.

The reported error is:

Could not start server! TypeError: Unknown method: listUsers
    at Mali.use (/Users/john/Developer/app/node_modules/mali/lib/app.js:217:21)

To Reproduce
Steps to reproduce the behavior:

Create the following protocol buffers:

protos/app/users/v1/users_service.proto

syntax = "proto3";

package app.users.v1;

import "app/type/v1/name.proto";

service UsersService {
  rpc ListUsers(ListUsersRequest) returns (ListUsersResponse) {}
}

message ListUsersRequest {
  string search = 1;
}

message ListUsersResponse {
  int64 count = 1;
  repeated User results = 2;
}

message User {
  app.type.v1.Name name = 1;
}

protos/app/type/v1/name.proto

syntax = "proto3";

package app.type.v1;

message Name {
  string first = 1;
  string last = 2;
}

Create a server

const main = async () => {
  const app = new Mali(
      "./protos/app/users/v1/users_service.proto",
      "app.users.v1.UsersService",
      {
        keepCase: true,
        longs: Number,
        defaults: true,
        oneofs: true,
        includeDirs: ["./protos"],
      }
    );

    app.use({
      listUsers: (ctx) => { ctx.res = { first: "First", last: "Last" } },
    });

    await app.start(`0.0.0.0:0`);
}

main()
  .then(() => console.log("Running!")
  .catch((error) => console.error(error));

Expected behavior
I expected my service to start with no issues.

Environment

  • Version: 0.44.1
  • Node.js version: 14.17.1
  • OS: MacOS 11.4
@anonrig
Copy link
Member

anonrig commented Jul 13, 2021

Wow this is a good one. Thanks for the fantastic bug report. I'll take a look at it asap.

@anonrig anonrig self-assigned this Jul 14, 2021
@anonrig
Copy link
Member

anonrig commented Jul 14, 2021

I've released a new version (0.44.2) fixing this. Hope it helps @eeston, thank you for the bug report. I hope not to see a similar bug report again in the future :))

@anonrig anonrig closed this as completed Jul 14, 2021
@eeston
Copy link
Contributor Author

eeston commented Jul 14, 2021

Thanks for the quick fix @anonrig. I'll test the update this evening 👍

@eeston
Copy link
Contributor Author

eeston commented Jul 14, 2021

No more issues! Thanks again @anonrig

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants