Unverified Commit bd391108 authored by Will Binns-Smith's avatar Will Binns-Smith Committed by GitHub

Turbopack: Include Next.js version in panic handler report (#78263)

parent 1411821c
use std::{env, process::Command, str}; use std::{env, fs, path::Path, process::Command, str};
use serde_json::Value;
extern crate napi_build; extern crate napi_build;
...@@ -6,6 +8,25 @@ fn main() -> anyhow::Result<()> { ...@@ -6,6 +8,25 @@ fn main() -> anyhow::Result<()> {
println!("cargo:rerun-if-env-changed=CI"); println!("cargo:rerun-if-env-changed=CI");
let is_ci = env::var("CI").is_ok_and(|value| !value.is_empty()); let is_ci = env::var("CI").is_ok_and(|value| !value.is_empty());
let nextjs_version = {
let package_json_path = Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../..")
.join("packages/next/package.json");
println!("cargo:rerun-if-changed={}", package_json_path.display());
let package_json_content = fs::read_to_string(&package_json_path)?;
let package_json: Value = serde_json::from_str(&package_json_content)?;
package_json["version"]
.as_str()
.expect("Expected a Next.js `version` string in its package.json")
.to_string()
};
// Make the Next.js version available as a build-time environment variable
println!("cargo:rustc-env=NEXTJS_VERSION={}", nextjs_version);
// Generates, stores build-time information as static values. // Generates, stores build-time information as static values.
// There are some places relying on correct values for this (i.e telemetry), // There are some places relying on correct values for this (i.e telemetry),
// So failing build if this fails. // So failing build if this fails.
......
...@@ -131,7 +131,11 @@ pub fn log_internal_error_and_inform(internal_error: &anyhow::Error) { ...@@ -131,7 +131,11 @@ pub fn log_internal_error_and_inform(internal_error: &anyhow::Error) {
"Turbopack Error: {}", "Turbopack Error: {}",
internal_error_str.lines().next().unwrap_or("Unknown") internal_error_str.lines().next().unwrap_or("Unknown")
); );
let version_str = format!("Turbopack version: `{}`", env!("VERGEN_GIT_DESCRIBE")); let version_str = format!(
"Turbopack version: `{}`\nNext.js version: `{}`",
env!("VERGEN_GIT_DESCRIBE"),
env!("NEXTJS_VERSION")
);
let new_discussion_url = if supports_hyperlinks::supports_hyperlinks() { let new_discussion_url = if supports_hyperlinks::supports_hyperlinks() {
"clicking here.".hyperlink( "clicking here.".hyperlink(
format!( format!(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment