Skip to content

Commit fd488ac

Browse files
committed
fix(options): Gate refresh spawn on successful OnceLock init; remove stale comment
Only spawn the background refresh task when OPTIONS.set() succeeds, so concurrent callers cannot produce multiple refresh tasks and filesystem watchers. Also remove a low-value inline comment in killswitches.rs.
1 parent b504654 commit fd488ac

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

objectstore-options/src/lib.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,14 @@ pub struct Killswitch {
113113
/// Must be called from within a Tokio runtime.
114114
pub fn init() -> Result<(), Error> {
115115
if OPTIONS.get().is_none() {
116-
// Load an initial snapshot and fail loudly if it can't be loaded. This ensures the application
117-
// will not silently run with defaults or fail later when options are accessed.
116+
// Load an initial snapshot and fail loudly if it can't be loaded. This ensures the
117+
// application will not silently run with defaults or fail later when options are accessed.
118118
let inner = sentry_options::Options::from_schemas(&[(NAMESPACE, SCHEMA)])?;
119-
let _ = OPTIONS.set(ArcSwap::from_pointee(Options::deserialize(&inner)?));
120-
tokio::spawn(refresh(inner));
119+
let initial = Options::deserialize(&inner)?;
120+
121+
if OPTIONS.set(ArcSwap::from_pointee(initial)).is_ok() {
122+
tokio::spawn(refresh(inner));
123+
}
121124
}
122125

123126
Ok(())

objectstore-server/src/killswitches.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ fn matches(
111111
}
112112
}
113113

114-
// Check service pattern if specified
115114
if let Some(ref pattern) = switch.service {
116115
// If pattern is specified but no service header present, don't match
117116
let Some(service_value) = service else {

0 commit comments

Comments
 (0)