summaryrefslogtreecommitdiff
path: root/cli/npm/resolvers/local.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2023-03-08 10:13:13 -0500
committerGitHub <noreply@github.com>2023-03-08 15:13:13 +0000
commit88b5fd90880b78498d0bbbdec6342b3db5887ef1 (patch)
treef3c0e4b99d3253c30c9a6f9625c7ac926d0b83c9 /cli/npm/resolvers/local.rs
parent72fe9bb47005e720444e65a66e91559287137780 (diff)
fix: attempt to only allow one deno process to update the node_modules folder at a time (#18058)
This is implemented in such a way that it should still allow processes to go through when a file lock wasn't properly cleaned up and the OS hasn't released it yet (but with a 200ms-ish delay). Closes #18039
Diffstat (limited to 'cli/npm/resolvers/local.rs')
-rw-r--r--cli/npm/resolvers/local.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/cli/npm/resolvers/local.rs b/cli/npm/resolvers/local.rs
index bf5b8529c..52a783823 100644
--- a/cli/npm/resolvers/local.rs
+++ b/cli/npm/resolvers/local.rs
@@ -10,6 +10,7 @@ use std::path::Path;
use std::path::PathBuf;
use crate::util::fs::symlink_dir;
+use crate::util::fs::LaxSingleProcessFsFlag;
use async_trait::async_trait;
use deno_ast::ModuleSpecifier;
use deno_core::anyhow::bail;
@@ -236,6 +237,13 @@ async fn sync_resolution_with_fs(
format!("Creating '{}'", deno_local_registry_dir.display())
})?;
+ let single_process_lock = LaxSingleProcessFsFlag::lock(
+ deno_local_registry_dir.join(".deno.lock"),
+ // similar message used by cargo build
+ "waiting for file lock on node_modules directory",
+ )
+ .await;
+
// 1. Write all the packages out the .deno directory.
//
// Copy (hardlink in future) <global_registry_cache>/<package_id>/ to
@@ -394,6 +402,8 @@ async fn sync_resolution_with_fs(
}
}
+ drop(single_process_lock);
+
Ok(())
}