Skip to content

fix(clippy): replace std::sync::Mutex with tokio::sync::Mutex in test#1031

Merged
jamesadevine merged 1 commit into
mainfrom
clippy-fixer/await-holding-lock-621ed288d730a1bc
Jun 15, 2026
Merged

fix(clippy): replace std::sync::Mutex with tokio::sync::Mutex in test#1031
jamesadevine merged 1 commit into
mainfrom
clippy-fixer/await-holding-lock-621ed288d730a1bc

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

What clippy found

clippy::await_holding_lock fired on a test in src/compile/source_path_guard.rs:

error: this `MutexGuard` is held across an await point
   --> src/compile/source_path_guard.rs:295:13
    |
295 |         let _guard = CWD_LOCK.lock().unwrap();
    |             ^^^^^^
note: these are all the await points this lock is held through
   --> src/compile/source_path_guard.rs:299:73
    |
299 |         let result = validate_workflow_source_path("workflows/evil.md").await;

The static CWD_LOCK was a std::sync::Mutex, and its guard was held across .await. Tokio can move a task to a different thread after an await resumes, so holding a std::sync::Mutex guard across an await point is a potential deadlock.

How it was fixed

Lint: clippy::await_holding_lock
File: src/compile/source_path_guard.rs
Fix: Changed the static from std::sync::Mutex::new(()) to tokio::sync::Mutex::const_new(()) (which is const-constructible for use in a static) and changed the lock call from .lock().unwrap() to .lock().await. The tokio::sync::Mutex is designed to be held across await points.

Verification

  • cargo build --all-targets
  • cargo test ✅ (all tests pass)
  • cargo clippy --all-targets --all-features --workspace -- -D warnings ✅ (clean)

Warning

Firewall blocked 2 domains

The following domains were blocked by the firewall during workflow execution:

  • spsprodeus21.vssps.visualstudio.com
  • spsprodweu4.vssps.visualstudio.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "spsprodeus21.vssps.visualstudio.com"
    - "spsprodweu4.vssps.visualstudio.com"

See Network Configuration for more information.

Generated by Clippy Fixer · 247 AIC · ⌖ 18.7 AIC · ⊞ 36.7K ·

The static CWD_LOCK in `rejects_relative_md_symlink_to_non_md_target`
held a `std::sync::Mutex` guard across an `.await` point, which
clippy::await_holding_lock flags as a potential deadlock hazard when
Tokio moves the task to another thread after the await.

Fix: use `tokio::sync::Mutex::const_new` (safe in const/static context)
and `.lock().await` so the guard is async-aware.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jamesadevine jamesadevine marked this pull request as ready for review June 15, 2026 20:19
@jamesadevine jamesadevine merged commit b7eee72 into main Jun 15, 2026
20 checks passed
@jamesadevine jamesadevine deleted the clippy-fixer/await-holding-lock-621ed288d730a1bc branch June 15, 2026 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant