Repository: denoland/deno
Pull request: fix: don't show panic traces for non-official builds

Don't show panic trace URLs during development. `panic-trace` feature is only enabled in CI.

Changed files:
filename: .github/workflows/ci.generate.ts
patch: @@ -701,13 +701,13 @@ const ci = {
           name: "Check tracing build",
           if:
             "matrix.job == 'test' && matrix.profile == 'debug' && matrix.os == 'linux' && matrix.arch == 'x86_64'",
-          run: "cargo check -p deno --features=lsp-tracing ",
+          run: "cargo check -p deno --features=lsp-tracing",
           env: { CARGO_PROFILE_DEV_DEBUG: 0 },
         },
         {
           name: "Build debug",
           if: "matrix.job == 'test' && matrix.profile == 'debug'",
-          run: "cargo build --locked --all-targets",
+          run: "cargo build --locked --all-targets --features=panic-trace",
           env: { CARGO_PROFILE_DEV_DEBUG: 0 },
         },
         // Uncomment for remote debugging
@@ -730,7 +730,7 @@ const ci = {
           run: [
             // output fs space before and after building
             "df -h",
-            "cargo build --release --locked --all-targets",
+            "cargo build --release --locked --all-targets --features=panic-trace",
             "df -h",
           ].join("\n"),
         },
@@ -887,7 +887,7 @@ const ci = {
             // Run full tests only on Linux.
             "matrix.os == 'linux'",
           ].join("\n"),
-          run: "cargo test --locked",
+          run: "cargo test --locked --features=panic-trace",
           env: { CARGO_PROFILE_DEV_DEBUG: 0 },
         },
         {
@@ -900,8 +900,8 @@ const ci = {
           run: [
             // Run unit then integration tests. Skip doc tests here
             // since they are sometimes very slow on Mac.
-            "cargo test --locked --lib",
-            "cargo test --locked --tests",
+            "cargo test --locked --lib --features=panic-trace",
+            "cargo test --locked --tests --features=panic-trace",
           ].join("\n"),
           env: { CARGO_PROFILE_DEV_DEBUG: 0 },
         },
@@ -914,7 +914,7 @@ const ci = {
             "github.repository == 'denoland/deno' &&",
             "!startsWith(github.ref, 'refs/tags/')))",
           ].join("\n"),
-          run: "cargo test --release --locked",
+          run: "cargo test --release --locked --features=panic-trace",
         },
         {
           name: "Configure hosts file for WPT",

filename: .github/workflows/ci.yml
patch: @@ -412,12 +412,12 @@ jobs:
         run: deno run --allow-write --allow-read --allow-run=git ./tests/node_compat/runner/setup.ts --check
       - name: Check tracing build
         if: '!(matrix.skip) && (matrix.job == ''test'' && matrix.profile == ''debug'' && matrix.os == ''linux'' && matrix.arch == ''x86_64'')'
-        run: 'cargo check -p deno --features=lsp-tracing '
+        run: cargo check -p deno --features=lsp-tracing
         env:
           CARGO_PROFILE_DEV_DEBUG: 0
       - name: Build debug
         if: '!(matrix.skip) && (matrix.job == ''test'' && matrix.profile == ''debug'')'
-        run: cargo build --locked --all-targets
+        run: cargo build --locked --all-targets --features=panic-trace
         env:
           CARGO_PROFILE_DEV_DEBUG: 0
       - name: Build release
@@ -427,7 +427,7 @@ jobs:
           github.repository == 'denoland/deno'))
         run: |-
           df -h
-          cargo build --release --locked --all-targets
+          cargo build --release --locked --all-targets --features=panic-trace
           df -h
       - name: Check deno binary
         if: '!(matrix.skip) && (matrix.job == ''test'')'
@@ -533,7 +533,7 @@ jobs:
           matrix.profile == 'debug' &&
           !startsWith(github.ref, 'refs/tags/') &&
           matrix.os == 'linux')
-        run: cargo test --locked
+        run: cargo test --locked --features=panic-trace
         env:
           CARGO_PROFILE_DEV_DEBUG: 0
       - name: 'Test (fast, debug)'
@@ -542,8 +542,8 @@ jobs:
           matrix.profile == 'debug' &&
           (startsWith(github.ref, 'refs/tags/') || matrix.os != 'linux'))
         run: |-
-          cargo test --locked --lib
-          cargo test --locked --tests
+          cargo test --locked --lib --features=panic-trace
+          cargo test --locked --tests --features=panic-trace
         env:
           CARGO_PROFILE_DEV_DEBUG: 0
       - name: Test (release)
@@ -553,7 +553,7 @@ jobs:
           (matrix.use_sysroot || (
           github.repository == 'denoland/deno' &&
           !startsWith(github.ref, 'refs/tags/'))))
-        run: cargo test --release --locked
+        run: cargo test --release --locked --features=panic-trace
       - name: Configure hosts file for WPT
         if: '!(matrix.skip) && (matrix.wpt)'
         run: ./wpt make-hosts-file | sudo tee -a /etc/hosts

filename: cli/Cargo.toml
patch: @@ -48,6 +48,8 @@ hmr = ["deno_runtime/hmr", "deno_snapshots/disable"]
 # Vendor zlib as zlib-ng
 __vendored_zlib_ng = ["flate2/zlib-ng-compat", "libz-sys/zlib-ng"]
 lsp-tracing = ["dep:tracing", "dep:tracing-subscriber", "dep:tracing-opentelemetry"]
+# Custom panic trace with `deno_panic`
+panic-trace = ["deno_panic"]
 
 [build-dependencies]
 deno_runtime = { workspace = true, features = ["include_js_files_for_snapshotting", "only_snapshotted_js_sources"] }
@@ -81,7 +83,7 @@ deno_media_type = { workspace = true, features = ["data_url", "decoding", "modul
 deno_npm.workspace = true
 deno_npm_cache.workspace = true
 deno_package_json = { workspace = true, features = ["sync"] }
-deno_panic = "0.1.0"
+deno_panic = { version = "0.1.0", optional = true }
 deno_path_util.workspace = true
 deno_resolver = { workspace = true, features = ["sync"] }
 deno_runtime = { workspace = true, features = ["include_js_files_for_snapshotting"] }

filename: cli/main.rs
patch: @@ -380,22 +380,26 @@ fn setup_panic_hook() {
     eprintln!("Args: {:?}", env::args().collect::<Vec<_>>());
     eprintln!();
 
-    let info = &deno_lib::version::DENO_VERSION_INFO;
-    let version =
-      if info.release_channel == deno_lib::shared::ReleaseChannel::Canary {
-        format!("{}+{}", deno_lib::version::DENO_VERSION, info.git_hash)
-      } else {
-        info.deno.to_string()
-      };
-
-    let trace = deno_panic::trace();
-    eprintln!("View stack trace at:");
-    eprintln!(
-      "https://panic.deno.com/v{}/{}/{}",
-      version,
-      env!("TARGET"),
-      trace
-    );
+    // Panic traces are not supported for custom/development builds.
+    #[cfg(feature = "panic-trace")]
+    {
+      let info = &deno_lib::version::DENO_VERSION_INFO;
+      let version =
+        if info.release_channel == deno_lib::shared::ReleaseChannel::Canary {
+          format!("{}+{}", deno_lib::version::DENO_VERSION, info.git_hash)
+        } else {
+          info.deno.to_string()
+        };
+
+      let trace = deno_panic::trace();
+      eprintln!("View stack trace at:");
+      eprintln!(
+        "https://panic.deno.com/v{}/{}/{}",
+        version,
+        env!("TARGET"),
+        trace
+      );
+    }
 
     orig_hook(panic_info);
     deno_runtime::exit(1);