Skip to content

Commit cbe57e9

Browse files
branchseerclaude
andcommitted
fix: store tracing guard in OnceLock to prevent early drop
The NAPI init() function was dropping the chrome-json tracing guard immediately, resulting in empty trace files from the Node.js process. Store it in a static OnceLock so it lives until process exit. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent db6d5c7 commit cbe57e9

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

  • packages/cli/binding/src

packages/cli/binding/src/lib.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,15 @@ use crate::cli::{
2828
BoxedResolverFn, CliOptions as ViteTaskCliOptions, ResolveCommandResult, ViteConfigResolverFn,
2929
};
3030

31+
/// Guard must be kept alive for the duration of the process when using chrome-json output.
32+
/// 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>>> =
34+
std::sync::OnceLock::new();
35+
3136
/// Module initialization - sets up tracing for debugging
3237
#[napi_derive::module_init]
3338
pub fn init() {
34-
crate::cli::init_tracing();
39+
TRACING_GUARD.get_or_init(crate::cli::init_tracing);
3540
}
3641

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

0 commit comments

Comments
 (0)