mozilla / sccache

Sccache is a ccache-like tool. It is used as a compiler wrapper and avoids compilation when possible. Sccache has the capability to utilize caching in remote storage environments, including various cloud storage options, or alternatively, in local storage.
Apache License 2.0
5.74k stars 540 forks source link

Add timeout to tcp connections #2231

Open Systemcluster opened 2 months ago

Systemcluster commented 2 months ago

Depending on system configuration, waiting for a connection error when checking for a running server can take a long time. In my local WSL installation, this is causing sccache to take several minutes to start up.

This PR replaces the two calls to connect with connect_timeout and adds a SCCACHE_CONNECTION_TIMEOUT environment variable for configuration. The code for reading the env var is copied from server.rs: https://github.com/mozilla/sccache/blob/9958e7c8a023b39df2c56073748d37a77febac03/src/server.rs#L94-L101

codecov-commenter commented 2 months ago

Codecov Report

Attention: Patch coverage is 30.00000% with 7 lines in your changes missing coverage. Please review.

Project coverage is 40.88%. Comparing base (0cc0c62) to head (7296b2b). Report is 68 commits behind head on main.

Files Patch % Lines
src/client.rs 33.33% 2 Missing and 4 partials :warning:
src/dist/client_auth.rs 0.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #2231 +/- ## ========================================== + Coverage 30.91% 40.88% +9.96% ========================================== Files 53 55 +2 Lines 20112 20675 +563 Branches 9755 9799 +44 ========================================== + Hits 6217 8452 +2235 - Misses 7922 8093 +171 + Partials 5973 4130 -1843 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

Systemcluster commented 1 month ago

@Xuanwo could you review this? I don't think it's a controversial change, but I can revert to calling connect without timeout if the environment variable isn't set otherwise.