connectrpc / connect-query-es

TypeScript-first expansion pack for TanStack Query that gives you Protobuf superpowers.
https://connectrpc.com/docs/web/query/getting-started
Apache License 2.0
237 stars 17 forks source link

Increase deadline/timeout of the RPC call #174

Closed thatsnoi closed 1 year ago

thatsnoi commented 1 year ago

Currently, I'm getting a 504 timeout error because the request takes too long. I haven't found any documentation on how to configure it. Im using createGrpcWebTransport to init the transport but AFAIK it doens't have an option to set a timeout (related https://github.com/connectrpc/connect-es/issues/799) How do I increase the deadline/timeout of my RPC Call while using tanstack?

thatsnoi commented 1 year ago

I see that I can set the timeout like this: createSomething.useMutation({ callOptions: { timeoutMs: 20000 } }) but this results in a CORS error: Access to fetch at 'http://localhost:8080/api.v1....' from origin 'http://localhost:3000' has been blocked by CORS policy: Request header field grpc-timeout is not allowed by Access-Control-Allow-Headers in preflight response.

timostamm commented 1 year ago

Hey Noah, I recommend to investigate what exactly is timing out first. A HTTP 504 response is not a typical response for a gRPC-web service. You can take a look at the response in the network inspector in the browser.

It seems most likely that the server or an intermediary is timing out, and responding with a HTTP 504 response, possibly with a HTML body with more details.

timostamm commented 1 year ago

We are currently adding documentation for the timeoutMs option here.

Your backend currently does not allow browser clients to send the grpc-timeout header, hence the CORS error. It needs to be explicitly allowed, see here.

thatsnoi commented 1 year ago

Thanks Timo! You were right, the issue was related to envoy proxy and not to the client :)