From 88b5fd90880b78498d0bbbdec6342b3db5887ef1 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Wed, 8 Mar 2023 10:13:13 -0500 Subject: 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 --- cli/npm/resolvers/local.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'cli/npm') 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) // to @@ -394,6 +402,8 @@ async fn sync_resolution_with_fs( } } + drop(single_process_lock); + Ok(()) } -- cgit v1.2.3