Skip to content

Conversation

@hanouticelina
Copy link
Contributor

Discussed internally with @Wauplin. If the HEAD call we make to fetch metadata when downloading files times out (10s), it falls back to locally cached files. if there's no cached file and the network is just slow, the download fails immediately, so this PR adds a retry mechanism with a longer timeout (60s) when no local file is found. The flow is like this:

1) HEAD request (10s timeout)
2) If timeout:
   - Check local cache -> return if found 
   - No local file -> retry with 60s timeout
   - Still fails -> raise error

_are_symlinks_supported_in_dir: dict[str, bool] = {}

# Internal retry timeout for metadata fetch when no local file exists
_ETAG_RETRY_TIMEOUT = 60
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to make it user configurable imo. i guess if a user has very slow network, they can already set HF_HUB_ETAG_TIMEOUT to increase the initial timeout

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree!

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Contributor

@Wauplin Wauplin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's funny how I thought this PR would be a lot messier 😄

_are_symlinks_supported_in_dir: dict[str, bool] = {}

# Internal retry timeout for metadata fetch when no local file exists
_ETAG_RETRY_TIMEOUT = 60
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree!

@Wauplin
Copy link
Contributor

Wauplin commented Nov 25, 2025

Just before merging, @LysandreJik @julien-c do you happen to have an opinion on this update? It looks sensible to me but since it touches a core part of the lib', I'd be glad to have your opinion

@julien-c
Copy link
Member

julien-c commented Nov 25, 2025

@Wauplin Zero opinion (nor objection) on my side

@Wauplin
Copy link
Contributor

Wauplin commented Nov 25, 2025

Great, that's all I wanted to hear 😁

@hanouticelina
Copy link
Contributor Author

let's merge then! 😄

@hanouticelina hanouticelina merged commit 337c18b into main Nov 26, 2025
24 checks passed
@hanouticelina hanouticelina deleted the retry-after-small-timeout branch November 26, 2025 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants