apollographql / router

A configurable, high-performance routing runtime for Apollo Federation 🚀
https://www.apollographql.com/docs/router/
Other
807 stars 272 forks source link

HTTP requests, canceled by the client, are not accounted for #3529

Closed lorf closed 6 months ago

lorf commented 1 year ago

Describe the bug HTTP requests to the router, canceled by the client (because of client timeout for example), are not accounted for: they doesn't count in the apollo_router_http_requests_total metric, the error doesn't get logged, and their trace spans don't indicate an error.

To Reproduce Steps to reproduce the behavior:

  1. Setup a configuration with router configured with "trace" logging level, metrics and tracing and a subgraph service that has large response time (e.g. 10 seconds).
  2. Make a request to router with timeout value set to a value lesser than response time of the subgraph service (e.g. 5 seconds) and wait for a timeout to occur.
  3. Observe that the fact of client closing the request was not logged even at a "trace" logging level, apollo_router_http_requests_total metric was not increased and router trace spans have no error=true attribute and have no log entries describing "request closed" error.

Expected behavior Requests, closed by clients, should be counted in apollo_router_http_requests_total metric (for example, using artificial HTTP status 499, like nginx does).

Trace spans of such requests should indicate an error and contain log entry describing the fact of closing the request from the client side.

The fact of closing the request by client should be logged using appropriate logging level.

Output

Desktop (please complete the following information):

Additional context This problem is quite annoying, because fellow developers can't find the cause of error like "request canceled", appearing in their service logs, using traces. Also we can't rely on router metrics or logs to catch these errors.

The root cause is, probably, an ignoring of some errors here: https://github.com/apollographql/router/blob/2a9349d4ab8c533de7be9333298ef2c15fc2b4f3/apollo-router/src/axum_factory/listeners.rs#L350 .

lorf commented 1 year ago

Related issue (closed): #2536

lorf commented 7 months ago

May be fixed by #4770

lorf commented 6 months ago

Fixed by #4770