Skip to content

Commit 556a60d

Browse files
branchseerclaude
andcommitted
fix: add Sync bound to TRACING_GUARD via Mutex wrapper
OnceLock requires its inner type to be Sync for static storage, but Box<dyn Any + Send> is not Sync. Wrap in Mutex to satisfy the bound. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent cbe57e9 commit 556a60d

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

  • packages/cli/binding/src

packages/cli/binding/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,14 @@ use crate::cli::{
3030

3131
/// Guard must be kept alive for the duration of the process when using chrome-json output.
3232
/// Stored in a OnceLock so it's never dropped until process exit.
33-
static TRACING_GUARD: std::sync::OnceLock<Option<Box<dyn std::any::Any + Send>>> =
33+
/// Wrapped in Mutex because `Box<dyn Any + Send>` is not Sync, but OnceLock requires Sync for statics.
34+
static TRACING_GUARD: std::sync::OnceLock<std::sync::Mutex<Option<Box<dyn std::any::Any + Send>>>> =
3435
std::sync::OnceLock::new();
3536

3637
/// Module initialization - sets up tracing for debugging
3738
#[napi_derive::module_init]
3839
pub fn init() {
39-
TRACING_GUARD.get_or_init(crate::cli::init_tracing);
40+
TRACING_GUARD.get_or_init(|| std::sync::Mutex::new(crate::cli::init_tracing()));
4041
}
4142

4243
/// Configuration options passed from JavaScript to Rust.

0 commit comments

Comments
 (0)