Don't generate crash reports on the Dev channel (#35915)

Julia Ryan created

We only want minidumps to be generated on actual release builds. Now we
avoid spawning crash handler processes for dev builds. To test
minidumping you can still set the `ZED_GENERATE_MINIDUMPS` env var which
force-enable the feature.

Release Notes:

- N/A

Change summary

Cargo.lock                    |  1 +
crates/crashes/Cargo.toml     |  1 +
crates/crashes/src/crashes.rs | 13 ++++++++++++-
3 files changed, 14 insertions(+), 1 deletion(-)

Detailed changes

Cargo.lock 🔗

@@ -4014,6 +4014,7 @@ dependencies = [
  "log",
  "minidumper",
  "paths",
+ "release_channel",
  "smol",
  "workspace-hack",
 ]

crates/crashes/Cargo.toml 🔗

@@ -10,6 +10,7 @@ crash-handler.workspace = true
 log.workspace = true
 minidumper.workspace = true
 paths.workspace = true
+release_channel.workspace = true
 smol.workspace = true
 workspace-hack.workspace = true
 

crates/crashes/src/crashes.rs 🔗

@@ -1,6 +1,7 @@
 use crash_handler::CrashHandler;
 use log::info;
 use minidumper::{Client, LoopAction, MinidumpBinary};
+use release_channel::{RELEASE_CHANNEL, ReleaseChannel};
 
 use std::{
     env,
@@ -9,7 +10,7 @@ use std::{
     path::{Path, PathBuf},
     process::{self, Command},
     sync::{
-        OnceLock,
+        LazyLock, OnceLock,
         atomic::{AtomicBool, Ordering},
     },
     thread,
@@ -22,7 +23,14 @@ pub static CRASH_HANDLER: AtomicBool = AtomicBool::new(false);
 pub static REQUESTED_MINIDUMP: AtomicBool = AtomicBool::new(false);
 const CRASH_HANDLER_TIMEOUT: Duration = Duration::from_secs(60);
 
+pub static GENERATE_MINIDUMPS: LazyLock<bool> = LazyLock::new(|| {
+    *RELEASE_CHANNEL != ReleaseChannel::Dev || env::var("ZED_GENERATE_MINIDUMPS").is_ok()
+});
+
 pub async fn init(id: String) {
+    if !*GENERATE_MINIDUMPS {
+        return;
+    }
     let exe = env::current_exe().expect("unable to find ourselves");
     let zed_pid = process::id();
     // TODO: we should be able to get away with using 1 crash-handler process per machine,
@@ -138,6 +146,9 @@ impl minidumper::ServerHandler for CrashServer {
 }
 
 pub fn handle_panic() {
+    if !*GENERATE_MINIDUMPS {
+        return;
+    }
     // wait 500ms for the crash handler process to start up
     // if it's still not there just write panic info and no minidump
     let retry_frequency = Duration::from_millis(100);