Unverified Commit b8d5f262 authored by Niklas Mischkulnig's avatar Niklas Mischkulnig Committed by GitHub

Turbopack: move write_version feature to env var (#81250)

This is useful for debugging infinite file write loop situations. Put it behind the env var `TURBO_ENGINE_WRITE_VERSION=1` to be able to debug this if other people want to debug this without recompiling Next.js
parent 7c048e33
...@@ -18,8 +18,6 @@ default = [] ...@@ -18,8 +18,6 @@ default = []
# A binary built with this option **is not portable**, the directory # A binary built with this option **is not portable**, the directory
# path will be embedded into the binary. # path will be embedded into the binary.
dynamic_embed_contents = [] dynamic_embed_contents = []
# Write a hashed version of each file to allow to debug conflicting writes
write_version = []
[lints] [lints]
workspace = true workspace = true
......
...@@ -32,7 +32,7 @@ use std::{ ...@@ -32,7 +32,7 @@ use std::{
io::{self, BufRead, BufReader, ErrorKind, Read}, io::{self, BufRead, BufReader, ErrorKind, Read},
mem::take, mem::take,
path::{MAIN_SEPARATOR, Path, PathBuf}, path::{MAIN_SEPARATOR, Path, PathBuf},
sync::Arc, sync::{Arc, LazyLock},
time::Duration, time::Duration,
}; };
...@@ -786,8 +786,12 @@ impl FileSystem for DiskFileSystem { ...@@ -786,8 +786,12 @@ impl FileSystem for DiskFileSystem {
#[cfg(target_family = "unix")] #[cfg(target_family = "unix")]
f.set_permissions(file.meta.permissions.into())?; f.set_permissions(file.meta.permissions.into())?;
f.flush()?; f.flush()?;
#[cfg(feature = "write_version")]
{ static WRITE_VERSION: LazyLock<bool> = LazyLock::new(|| {
std::env::var_os("TURBO_ENGINE_WRITE_VERSION")
.is_some_and(|v| v == "1" || v == "true")
});
if *WRITE_VERSION {
let mut full_path = full_path.to_owned(); let mut full_path = full_path.to_owned();
let hash = hash_xxh3_hash64(file); let hash = hash_xxh3_hash64(file);
let ext = full_path.extension(); let ext = full_path.extension();
......
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