Comments (15)
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.
Hey, Thank you for reporting this. I have added this to my backlog.
from protoc-gen-ts.
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.
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.
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.
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.
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.
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.
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.
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.
So, if metadata
is not passed are we gonna create a new empty one?
from protoc-gen-ts.
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.
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.
@maZahaca I will try to implement it today.
from protoc-gen-ts.
#72 already fixes this problem but it introduces some breaking.
from protoc-gen-ts.
Related Issues (20)
- Generation with target=web HOT 3
- Cannot use ‘in’ operator to search for ‘Array’ in undefined; HOT 2
- Get `Error: EAGAIN: resource temporarily unavailable, read` when maybe many files are specified as input HOT 1
- Support Promises in Server Definition
- npm package needs publishing to include fix for typescript >= 5 HOT 8
- The namespace 'Google protobuf' does not have an exported member 'BinaryWriter' HOT 1
- `toObject()` inferred type too long when compiled with `declaration: true` HOT 1
- More fleshed out example
- Proto with oneof and other field is generated as union instead of intersect
- `Property 'xy' of type 'z' is not assignable to 'string' index type 'UntypedHandleCall'.` for class properties
- Add `as const` to UnimplementedService definition
- TSC error with compiler option noUnusedLocals HOT 2
- import_style=es6 ? HOT 1
- Consuming JSON For Tests and Converting To Protoc HOT 1
- I need to generate file interface IUser {} HOT 3
- Property 'Buffer' does not exist on type 'typeof globalThis' HOT 2
- [rust] Error starting the proto build with new rust wasm package. Error when executing /usr/bin/protoc-gen-ts HOT 1
- [rust] proto3 optional fields support
- methodName conflict HOT 1
- snake_case to camelCase conversion HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from protoc-gen-ts.