]> git.proxmox.com Git - cargo.git/commit
Give a better error message when crates.io requests time out
authorSean Griffin <sean@seantheprogrammer.com>
Mon, 13 May 2019 20:18:42 +0000 (14:18 -0600)
committerSean Griffin <sean@seantheprogrammer.com>
Mon, 13 May 2019 20:31:26 +0000 (14:31 -0600)
commit35cb07944cf98f26e308c944a361d6f4f2b94f01
tree96350216f158581db9e10f772957934f785f0d6f
parentd56af31df1fbe45105ccd3b633297b2bc61e7405
Give a better error message when crates.io requests time out

crates.io is hosted on Heroku, which means we have a hard 30 second time
limit on all requests. Typically this is only hit when someone is
attempting to upload a crate so large that it would have been eventually
rejected anyway, but it can also happen if a user is on a very slow
internet connection.

When this happens, the request is terminated by the platform and we have
no control over the response that gets sent. This results in the user
getting a very unhelpful error message from Cargo, and some generic
error page HTML spat out into their terminal. We could work around this
on our end by adding a 29 second timeout *somewhere else* in the stack,
but we have a lot of layers that buffer requests to protect against slow
client attacks, and it'd be a pretty decent amount of work. Since we
eventually want to switch over to having Cargo do the S3 upload instead
of us, it doesn't make sense to spend so much time on an error scenario
that eventually will go away.

I've tried to keep this uncoupled from crates.io as much as possible,
since alternate registries might not be hosted on Heroku or have the
same restricitions. But I figure "a 503 that took more than 30 seconds"
is a safe bet on this being hit. If we're ok with coupling this to
crates.io, I'd like to include "If your crate is less than 10MB you can
email help@crates.io for assistance" in the error message.

Ref https://github.com/rust-lang/crates.io/issues/1709
src/crates-io/lib.rs