Skip to content

Commit

Permalink
fix: avoid panic when re-setting global default subscriber (#5129)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wodann committed Apr 17, 2024
1 parent 3b36d76 commit a41cb44
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/twelve-ducks-exercise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nomicfoundation/edr": patch
---

Fixed panic when re-setting global default subscriber
5 changes: 3 additions & 2 deletions crates/edr_napi/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ impl EdrContext {

#[derive(Debug)]
pub struct Context {
_subscriber_guard: tracing::subscriber::DefaultGuard,
#[cfg(feature = "tracing")]
_tracing_write_guard: tracing_flame::FlushGuard<std::io::BufWriter<std::fs::File>>,
}
Expand Down Expand Up @@ -63,10 +64,10 @@ impl Context {
#[cfg(feature = "tracing")]
let subscriber = subscriber.with(flame_layer);

tracing::subscriber::set_global_default(subscriber)
.expect("Could not set global default tracing subscriber");
let subscriber_guard = tracing::subscriber::set_default(subscriber);

Ok(Self {
_subscriber_guard: subscriber_guard,
#[cfg(feature = "tracing")]
_tracing_write_guard: guard,
})
Expand Down

0 comments on commit a41cb44

Please sign in to comment.