Comments (8)
How are you getting this result? When I run the examples I don't see that behavior, I see the intended behavior of setting the deadline and having requests end with the DEADLINE_EXCEEDED status.
from grpc-node.
@murgatroid99, I'll have to dig through the commit history to find the commit where it was failing. The working code looks like so:
const call = client.unary(
uReq,
metadata,
callOptions,
(err: ServiceError | null, response: UnaryResponse) => {
// ...
}
);
Previously, based on the docs indicating a deadline
in the second parameter, I think the second paramter was previously a combined object with both request metadata and a deadline key. It's unclear from the docs that wouldn't work. And when there was no other request metadata, it would have basically looked like exactly like the example.
@smaye81, can you help me unearth a better snippet that repros this?
from grpc-node.
Just to clarify, the handler does inspect the arguments to dynamically decide how to interpret the positional arguments. It is unambiguous because metadata
must be an instance of the Metadata
class, callOptions
must be an object, and the callback
argument must be a function.
from grpc-node.
Ah, I see. I still think the docs/examples could use an update to clarify this. I think our code may have been putting the deadline into a Metadata
class, since it wasn't immediately obvious from the examples that is wrong.
from grpc-node.
I'm not sure what you mean about putting the deadline into a Metadata class. That's clearly not what the example shows.
For clarification, I think the examples collectively cover the different cases. The hello world example demonstrates making a request without providing either metadata or callOptions. The deadline example demonstrates making a request with callOptions but not metadata. The metadata example demonstrates making a request with metadata but not callOptions. And you seem to have figured out how to send both from other information.
from grpc-node.
Looks like the issues arise from using TypeScript. The .ts.d
file generated has signatures like so:
public unary(request: test.UnaryRequest, callback: (error: grpc.ServiceError | null, response: test.UnaryResponse) => void): grpc.ClientUnaryCall;
public unary(request: test.UnaryRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: test.UnaryResponse) => void): grpc.ClientUnaryCall;
public unary(request: test.UnaryRequest, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: test.UnaryResponse) => void): grpc.ClientUnaryCall;
None of those signatures accepts a CallOptions
as the second parameter, but the examples clearly show adding the deadline to the second parameter. I think the TS generator needs to also emit another signature:
public unary(request: test.UnaryRequest, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: test.UnaryResponse) => void): grpc.ClientUnaryCall;
from grpc-node.
Which code generator is producing those TypeScript files?
from grpc-node.
Actually in looking at how we are generating the d.ts
files, it is using grpc_tools_node_protoc_ts
, which isn't a part of grpc-js. I assumed that the grpc_tools
prefix meant it was part of the grpc-tools package. We will follow up with that plugin author and we can close this issue.
from grpc-node.
Related Issues (20)
- Compression handling has some issues
- Cardinality violations should use error code “unimplemented” HOT 3
- Servers send grpc-message trailer even when no error HOT 1
- successful calls still emit 'cancelled' as of v1.10.x HOT 2
- grpc-loader: Expose field options HOT 3
- `@grpc/grpc-js@latest` is pointing to an old version HOT 1
- Implement authority overrides in the DNS resolver HOT 7
- return process.dlopen(module, path.toNamespacedPath(filename));/issues/233 HOT 1
- gRPC-JS client hangs when target server restarts HOT 1
- Infinite loop in LoadBalancingCall.doPick after closing the client HOT 2
- `grpc_tools_node_protoc` generated code does not build for `--moduleResolution=nodenext` HOT 3
- Performance degradation in high throughput applications due to DNS resolution bug HOT 5
- GRPC 2 UNKNOWN error.details always empty string HOT 3
- a HOT 1
- Cannot find module 'node:dns' HOT 3
- How to reload ssl ctx without restart grpc-server?
- Simultaneously ping may cause server hangs HOT 6
- gRPC deadline when hitting a server using ring_hash LB HOT 5
- RESOURCE_EXHAUSTED: Received message larger than max (808722544 vs 4194304) in version 1.10.9 HOT 3
- How to use InterceptorProvider for GRPC clients HOT 1
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 grpc-node.