Skip to content

Support retry mechanism for Git operations when server returns 429 Too Many Requests #15856

@BiagioFesta

Description

@BiagioFesta

Problem

Cargo's net.retry configuration currently doesn't affect Git operations when they fail.

In enterprise environments, it's common to have internal Git servers hosting private dependencies. These servers often implement rate limiting to prevent overload, especially when many builds happen in parallel (CI/CD pipelines, multiple developers, etc.).

Currently, when the Git server returns a 429, the build fails immediately:

$ cargo build
remote: Too Many Requests
fatal: unable to access 'https://myserver:8888/git/': The requested URL returned error: 429
error: failed to get my_beauty_lib as a dependency of package ...

Am I wondering whether it could be an option to allow cargo git invocation retry in this case.

Proposed Solution

Extend Cargo's net.retry configuration (or introduce a new net.git-retry option) to handle Git operation retries, particularly for rate-limit (429) responses.

Notes

IINM, even with net.git-fetch-with-cli, it seems this is not possible, as it seems git does not support retry config; so the caller (cargo in this case) is required to implement the retry mechanism.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-configurationArea: cargo config files and env varsA-gitArea: anything dealing with gitA-networkingArea: networking issues, curl, etc.C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`S-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions