Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/plugin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ scc = { workspace = true }
serde = { workspace = true, features = ["rc"] }
serde_json = { workspace = true }
starbase_styles = { workspace = true }
starbase_utils = { workspace = true, features = ["json"] }
starbase_utils = { workspace = true, features = ["fs-lock", "json"] }
thiserror = { workspace = true }
tokio = { workspace = true }
tracing = { workspace = true }
warpgate = { workspace = true }

[dev-dependencies]
starbase_sandbox = { workspace = true }
tokio = { workspace = true }

[lints]
workspace = true
18 changes: 18 additions & 0 deletions crates/plugin/src/plugin_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,24 @@ impl<T: Plugin> PluginRegistry<T> {
"Attempting to load and register plugin",
);

// Acquire a cross-process file lock before downloading the WASM plugin.
// Multiple parallel tests or CI jobs may attempt to download the same
// plugin file simultaneously; on Windows, concurrent file writes cause
// "uncategorized error" failures. The lock serializes writes so that
// any waiting process finds the file already cached on acquisition.
let lock_dir = self
.host_data
.moon_env
.plugins_dir
.join(self.type_of.get_dir_name())
.join("locks");
fs::create_dir_all(&lock_dir)?;
let lock_path = lock_dir.join(format!("{}.lock", entry.key().as_str()));
let _plugin_lock =
tokio::task::spawn_blocking(move || fs::lock_file(lock_path))
.await
.map_err(|e| miette::miette!("Plugin lock task panicked: {e}"))??;

// Load the WASM file (this must happen first because of async)
let plugin_file = self.loader.load_plugin(entry.key(), locator).await?;

Expand Down