Coder Social home page Coder Social logo

Comments (8)

murgatroid99 avatar murgatroid99 commented on September 27, 2024

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.

jhump avatar jhump commented on September 27, 2024

@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.

murgatroid99 avatar murgatroid99 commented on September 27, 2024

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.

jhump avatar jhump commented on September 27, 2024

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.

murgatroid99 avatar murgatroid99 commented on September 27, 2024

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.

jhump avatar jhump commented on September 27, 2024

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.

murgatroid99 avatar murgatroid99 commented on September 27, 2024

Which code generator is producing those TypeScript files?

from grpc-node.

smaye81 avatar smaye81 commented on September 27, 2024

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)

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.