Skip to content

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

@eeston

Description

@eeston

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions