Git Product home page Git Product logo

Comments (15)

thesayyn avatar thesayyn commented on May 24, 2024 1

https://github.com/thesayyn/protoc-gen-ts/releases/tag/0.3.9 has been released.

This is fixed in the new release.

from protoc-gen-ts.

thesayyn avatar thesayyn commented on May 24, 2024

Hey, Thank you for reporting this. I have added this to my backlog.

from protoc-gen-ts.

thesayyn avatar thesayyn commented on May 24, 2024

Hey @flolu

Could please try this again with the latest version of the plugin. it should be working

Feel free to reopen if the problem persists

from protoc-gen-ts.

maZahaca avatar maZahaca commented on May 24, 2024

I've just installed the latest version 0.3.8 and it seems that the issue is still there:

TypeError: Cannot read property 'interceptors' of undefined

      1366 |         }
      1367 |         CreateAccount(request: Request, metadata?: grpc_1.Metadata): Promise<Response> {
    > 1368 |             return new Promise((resolve, reject) => super["CreateAccount"](request, metadata, (error: grpc_1.ServiceError, response: Response) => {
           |                                                                           ^
      1369 |                 if (error) {
      1370 |                     reject(error);

@thesayyn any thoughts what could be the root of this issue?

from protoc-gen-ts.

maZahaca avatar maZahaca commented on May 24, 2024

@thesayyn

Btw, when no promises version the call looks like the following, and it works well.

...
client['CreateAccount'](
   new proto.namespace_test.Request(),
   callback,
);

as you can see there is no metadata parameter in the middle of params compare to Promise version.

from protoc-gen-ts.

thesayyn avatar thesayyn commented on May 24, 2024

Hey @maZahaca

Could you please provide some additional information such as the version of the "google-protobuf" and "@grpc/grpc-js" or "grpc" that you are using?

from protoc-gen-ts.

maZahaca avatar maZahaca commented on May 24, 2024

sure @thesayyn, here is my package.json:

{
  "dependencies": {
    "@grpc/grpc-js": "^1.3.4",
    "google-protobuf": "^3.15.5"
  },
  "devDependencies": {
    "@types/google-protobuf": "^3.15.0",
    "@types/node": "^15.12.4",
    "protoc-gen-ts": "^0.3.8",
    "typescript": "^4.3.4"
  }
}

from protoc-gen-ts.

thesayyn avatar thesayyn commented on May 24, 2024

It is so strange that I can not reproduce this problem. It would be so sweet if you could provide a minimal reproduction repository that I can use to reproduce this problem.

from protoc-gen-ts.

kluiverjh avatar kluiverjh commented on May 24, 2024

Got the same error. When I generate the proto code in the non experimental way; and apply manual the promise as done in the experimental mode I can reproduce the problem. When the meta data is passed in as null, the error "Cannot read property 'interceptors' of undefined" is returned.

This returns the 'Cannot read property 'interceptors' of undefined'
WithMeta_promise(request, meta) {
return new Promise((resolve, reject) =>
this.client['CreateAccount'](
request,
meta,
(error, response) => {
if (error) {
reject(error);
} else {
resolve(response);
}
},
),
);
}
This doesn't returns the 'Cannot read property 'interceptors' of undefined'
WithoutMeta_promise(request) {
return new Promise((resolve, reject) =>
this.client['CreateAccount'](
request,
(error, response) => {
if (error) {
reject(error);
} else {
resolve(response);
}
},
),
);
}

from protoc-gen-ts.

thesayyn avatar thesayyn commented on May 24, 2024

Got the same error. When I generate the proto code in the non experimental way; and apply manual the promise as done in the experimental mode I can reproduce the problem. When the meta data is passed in as null, the error "Cannot read property 'interceptors' of undefined" is returned.

This returns the 'Cannot read property 'interceptors' of undefined'
WithMeta_promise(request, meta) {
return new Promise((resolve, reject) =>
this.client['CreateAccount'](
request,
meta,
(error, response) => {
if (error) {
reject(error);
} else {
resolve(response);
}
},
),
);
}
This doesn't returns the 'Cannot read property 'interceptors' of undefined'
WithoutMeta_promise(request) {
return new Promise((resolve, reject) =>
this.client['CreateAccount'](
request,
(error, response) => {
if (error) {
reject(error);
} else {
resolve(response);
}
},
),
);
}

I have suspected this. Great finding!

Perhaps we add some overloads to this function and have a conditional call based on the availability of variables.

I would welcome a PR if you are up to it.

from protoc-gen-ts.

maZahaca avatar maZahaca commented on May 24, 2024

So, if metadata is not passed are we gonna create a new empty one?

from protoc-gen-ts.

thesayyn avatar thesayyn commented on May 24, 2024

Nope. if the metadata is not present we not gonna pass it at all just to be safe.

If it does not hurt to pass it, we can just construct a new one whenever the metadata is empty but I am not sure about the internal behavior of metadata argument and what would happen if we were to pass an empty one.

so it would look like this

method(request: RequestType): Promise<ResponseType>
method(request: RequestType, metadata: Metadata): Promise<ResponseType>
method(request: RequestType, metadata?: Metadata): Promise<ResponseType>

client.method(new RequestType()); // it is fine 
client.method(new RequestType(), new Metadata()) // also fine

and the implementation would look like;

if (metadata) {
   super.get(request, metadata, callback);
} else {
  super.get(request, callback);
}

from protoc-gen-ts.

maZahaca avatar maZahaca commented on May 24, 2024

Anytime soon we can have this implemented? I took a look into the code and realized that I'm not too familiar with it.

from protoc-gen-ts.

thesayyn avatar thesayyn commented on May 24, 2024

@maZahaca I will try to implement it today.

from protoc-gen-ts.

thesayyn avatar thesayyn commented on May 24, 2024

#72 already fixes this problem but it introduces some breaking.

from protoc-gen-ts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.