Skip to content

Commit 2c993e5

Browse files
authored
Make delay between crate publishes configurable and reduce default (#3290)
This change reduces the time delay between crate publishes from 5 seconds down to 1, and makes it configurable in case this leads to release issues. ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._
1 parent 82b190c commit 2c993e5

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

tools/ci-build/publisher/src/subcommand/publish.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ use std::path::{Path, PathBuf};
2323
use std::time::Duration;
2424
use tracing::info;
2525

26+
const DEFAULT_DELAY_MILLIS: usize = 1000;
27+
2628
#[derive(Parser, Debug)]
2729
pub struct PublishArgs {
2830
/// Path containing the crates to publish. Crates will be discovered recursively
@@ -32,18 +34,24 @@ pub struct PublishArgs {
3234
/// Don't prompt for confirmation before publishing
3335
#[clap(short('y'))]
3436
skip_confirmation: bool,
37+
38+
/// Time delay between crate publishes to avoid crates.io throttling errors.
39+
#[clap(long)]
40+
delay_millis: Option<usize>,
3541
}
3642

3743
pub async fn subcommand_publish(
3844
PublishArgs {
3945
location,
4046
skip_confirmation,
47+
delay_millis,
4148
}: &PublishArgs,
4249
) -> Result<()> {
4350
// Make sure cargo exists
4451
cargo::confirm_installed_on_path()?;
4552

4653
let location = resolve_publish_location(location);
54+
let delay_millis = Duration::from_millis(delay_millis.unwrap_or(DEFAULT_DELAY_MILLIS) as _);
4755

4856
info!("Discovering crates to publish...");
4957
let (batches, stats) = discover_and_validate_package_batches(Fs::Real, &location).await?;
@@ -60,7 +68,7 @@ pub async fn subcommand_publish(
6068
publish(&package.handle, &package.crate_path).await?;
6169

6270
// Keep things slow to avoid getting throttled by crates.io
63-
tokio::time::sleep(Duration::from_secs(5)).await;
71+
tokio::time::sleep(delay_millis).await;
6472

6573
// Sometimes it takes a little bit of time for the new package version
6674
// to become available after publish. If we proceed too quickly, then

0 commit comments

Comments
 (0)