Skip to content

Commit

Permalink
Panic like a pro (thanks john)
Browse files Browse the repository at this point in the history
  • Loading branch information
smklein committed Oct 16, 2024
1 parent 7f2b2bd commit 6326cde
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion nexus/db-queries/src/db/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,16 @@ impl Drop for Pool {
// With this check, we'll reliably panic (rather than flake) if the pool
// is dropped without terminating these worker tasks.
if !self.terminated.load(std::sync::atomic::Ordering::SeqCst) {
panic!("Pool dropped without invoking `terminate`");
// If we're already panicking, don't panic again.
// Doing so can ruin test handlers by aborting the process.
//
// Instead, just drop a message to stderr and carry on.
let msg = "Pool dropped without invoking `terminate`";
if std::thread::panicking() {
eprintln!("{msg}");
} else {
panic!("{msg}");
}
}
}
}

0 comments on commit 6326cde

Please sign in to comment.