Byron / google-apis-rs

A binding and CLI generator for all Google APIs
http://byron.github.io/google-apis-rs
Other
1.02k stars 136 forks source link

No way to set request timeouts #248

Closed nagisa closed 3 years ago

nagisa commented 4 years ago

We have been using pubsub1 and starting today I've seen some serious issues stemming from undelying I/O. I find my application sitting in the following stack trace pretty much indefinitely:

    #0  0x00007fc104cb6876 in recv () from /nix/store/6yaj6n8l925xxfbcd65gzqx3dz7idrnn-glibc-2.27/lib/libpthread.so.0
    #1  0x000055d65f83466a in <std::net::tcp::TcpStream as std::io::Read>::read ()
    #2  0x000055d65f3ccb8a in <hyper::net::HttpStream as std::io::Read>::read ()
    #3  0x000055d65f3da2f5 in rustls::msgs::deframer::MessageDeframer::read ()
    #4  0x000055d65f3d58e1 in <rustls::client::ClientSession as rustls::session::Session>::read_tls ()
    #5  0x000055d65f3cd006 in <hyper_rustls::TlsStream as std::io::Read>::read ()
    #6  0x000055d65f3cd63f in <hyper_rustls::WrappedStream as std::io::Read>::read ()
    #7  0x000055d65f278086 in <hyper::net::HttpsStream<S> as std::io::Read>::read ()
    #8  0x000055d65f453ec4 in <hyper::http::h1::Http11Message as hyper::http::message::HttpMessage>::get_incoming ()
    #9  0x000055d65f457947 in hyper::client::response::Response::with_message ()
    #10 0x000055d65f46792d in hyper::client::request::Request<hyper::net::Streaming>::send ()
    #11 0x000055d65f45ef20 in hyper::client::RequestBuilder::send ()
    #12 0x000055d65f38f23c in google_pubsub1::ProjectTopicPublishCall<C,A>::doit ()

which seems to suggest that there has been some change in how google handles responses (for the worse) and it is effectively DoSing me. I would have just gone ahead and set some timeout, but this library doesn't appear to expose that functionality!

FWIW noting the sad results from https://medium.com/@shnatsel/smoke-testing-rust-http-clients-b8f2ee5db4e6 the sensible solution might be having these libraries not make the choice for http library at all and just generate Requests which people would then use with whatever version of whatever library they want?

Byron commented 4 years ago

Thanks for using this client and for posting here. I loved the article, for the most part, and it reminded me about the painful truth that decent software is incredibly hard to produce, even though Rust gives us a chance to accomplish this.

Even though this crate doesn't make it obvious how to deal with timeouts, the consumer has full control over the the client used. Thus I wonder if setting the read timeout would be sufficient for your case?

nagisa commented 4 years ago

You’re right, I missed this entirely. While it is a larger hammer than I would like, its definitely good enough for now.