-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(turborepo): Adopt std::cell::OnceCell #5763
Changes from 1 commit
b5afa5d
bc1b761
6389eaa
d59ef93
dd48a2e
59a6188
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,8 @@ | |
use config::{Config, ConfigError, Environment}; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use crate::config::Error; | ||
|
||
const DEFAULT_TIMEOUT: u64 = 20; | ||
|
||
#[derive(Debug, Clone, PartialEq, Eq)] | ||
|
@@ -49,7 +51,7 @@ | |
self | ||
} | ||
|
||
pub fn load(self) -> Result<ClientConfig> { | ||
pub fn load(self) -> Result<ClientConfig, Error> { | ||
let Self { | ||
remote_cache_timeout, | ||
environment, | ||
|
@@ -60,17 +62,12 @@ | |
.add_source(Environment::with_prefix("turbo").source(environment)) | ||
.set_override_option("remote_cache_timeout", remote_cache_timeout)? | ||
.build()? | ||
// Deserialize is the only user-input-fallible step. | ||
// Everything else is programmer error. | ||
// This goes wrong when TURBO_REMOTE_CACHE_TIMEOUT can't be deserialized to u64 | ||
.try_deserialize(); | ||
|
||
// This goes wrong when TURBO_REMOTE_CACHE_TIMEOUT can't be deserialized to u64 | ||
match config_attempt { | ||
Err(_) => Ok(ClientConfig { | ||
config: ClientConfigValue { | ||
remote_cache_timeout: DEFAULT_TIMEOUT, | ||
}, | ||
}), | ||
Ok(config) => Ok(ClientConfig { config }), | ||
} | ||
Comment on lines
-65
to
-73
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This behavior does not match any of our other configuration loaders which fail hard in the event of garbage input. We can come back and create "this error is only a warning" behavior if we want to do so later, but for now make the failure mode consistent. |
||
config_attempt.map(|config| ClientConfig { config }) | ||
Check failure on line 70 in crates/turborepo-lib/src/config/client.rs GitHub Actions / Build Turborepo (ubuntu, ubuntu-latest)
|
||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a rigid new pattern here across all of the config loading sources. It makes it super-clear what's happening each time.