Skip to content

Show warning if file lock acquiring blocks for long time#1353

Merged
j178 merged 3 commits intomasterfrom
lock
Jan 18, 2026
Merged

Show warning if file lock acquiring blocks for long time#1353
j178 merged 3 commits intomasterfrom
lock

Conversation

@j178
Copy link
Owner

@j178 j178 commented Jan 14, 2026

Closes #1184

@j178 j178 added the enhancement New feature or request label Jan 14, 2026
@codecov
Copy link

codecov bot commented Jan 14, 2026

Codecov Report

❌ Patch coverage is 94.18605% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.38%. Comparing base (845d849) to head (b409882).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
crates/prek/src/fs.rs 92.59% 4 Missing ⚠️
crates/prek/src/cli/reporter.rs 96.15% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1353      +/-   ##
==========================================
+ Coverage   90.33%   90.38%   +0.04%     
==========================================
  Files          82       82              
  Lines       16147    16210      +63     
==========================================
+ Hits        14587    14652      +65     
+ Misses       1560     1558       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions
Copy link

github-actions bot commented Jan 14, 2026

📦 Cargo Bloat Comparison

Binary size change: +0.00% (22.4 MiB → 22.4 MiB)

Expand for cargo-bloat output

Head Branch Results

 File  .text    Size        Crate Name
 0.3%   0.8% 72.1KiB        prek? <prek::cli::Command as clap_builder::derive::Subcommand>::augment_subcommands
 0.2%   0.6% 53.8KiB         prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.2%   0.5% 49.8KiB         prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.2%   0.5% 46.0KiB         prek prek::run::{{closure}}
 0.2%   0.5% 42.5KiB         prek prek::cli::run::run::run::{{closure}}
 0.2%   0.4% 35.1KiB         prek prek::languages::<impl prek::config::Language>::install::{{closure}}
 0.1%   0.3% 31.8KiB        prek? <prek::cli::RunArgs as clap_builder::derive::Args>::augment_args
 0.1%   0.3% 29.2KiB  serde_json? <&mut serde_json::de::Deserializer<R> as serde_core::de::Deserializer>::deserialize_struct
 0.1%   0.3% 27.6KiB         prek prek::identify::by_extension::{{closure}}
 0.1%   0.2% 21.5KiB         prek prek::archive::unzip::{{closure}}
 0.1%   0.2% 21.3KiB clap_builder clap_builder::parser::parser::Parser::get_matches_with
 0.1%   0.2% 21.0KiB         prek prek::hooks::meta_hooks::MetaHooks::run::{{closure}}
 0.1%   0.2% 20.8KiB         prek prek::hooks::meta_hooks::MetaHooks::run::{{closure}}
 0.1%   0.2% 19.6KiB         prek <prek::languages::ruby::ruby::Ruby as prek::languages::LanguageImpl>::install::{{closure}}
 0.1%   0.2% 19.2KiB         prek prek::cli::run::filter::collect_files_from_args::{{closure}}
 0.1%   0.2% 18.9KiB         prek prek::cli::run::filter::collect_files_from_args::{{closure}}
 0.1%   0.2% 18.6KiB         ring ring_core_0_17_14__x25519_ge_frombytes_vartime
 0.1%   0.2% 18.2KiB   hyper_util hyper_util::client::legacy::client::Client<C,B>::send_request::{{closure}}
 0.1%   0.2% 18.1KiB    [Unknown] fe_loose_invert
 0.1%   0.2% 17.7KiB         prek prek::cli::run::filter::collect_files_from_args::{{closure}}
36.7%  91.8%  8.2MiB              And 19762 smaller methods. Use -n N to show more.
39.9% 100.0%  9.0MiB              .text section size, the file size is 22.4MiB

Base Branch Results

 File  .text    Size        Crate Name
 0.3%   0.8% 71.5KiB        prek? <prek::cli::Command as clap_builder::derive::Subcommand>::augment_subcommands
 0.2%   0.6% 54.6KiB         prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.2%   0.5% 49.8KiB         prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.2%   0.5% 46.1KiB         prek prek::run::{{closure}}
 0.2%   0.5% 42.9KiB         prek prek::cli::run::run::run::{{closure}}
 0.2%   0.5% 42.7KiB         prek prek::identify::by_extension::{{closure}}
 0.2%   0.4% 35.1KiB         prek prek::languages::<impl prek::config::Language>::install::{{closure}}
 0.1%   0.3% 31.6KiB        prek? <prek::cli::RunArgs as clap_builder::derive::Args>::augment_args
 0.1%   0.3% 29.2KiB  serde_json? <&mut serde_json::de::Deserializer<R> as serde_core::de::Deserializer>::deserialize_struct
 0.1%   0.2% 21.6KiB         prek prek::archive::unzip::{{closure}}
 0.1%   0.2% 21.3KiB clap_builder clap_builder::parser::parser::Parser::get_matches_with
 0.1%   0.2% 21.0KiB         prek prek::hooks::meta_hooks::MetaHooks::run::{{closure}}
 0.1%   0.2% 20.8KiB         prek prek::hooks::meta_hooks::MetaHooks::run::{{closure}}
 0.1%   0.2% 19.6KiB         prek <prek::languages::ruby::ruby::Ruby as prek::languages::LanguageImpl>::install::{{closure}}
 0.1%   0.2% 19.2KiB         prek prek::cli::run::filter::collect_files_from_args::{{closure}}
 0.1%   0.2% 18.9KiB         prek prek::cli::run::filter::collect_files_from_args::{{closure}}
 0.1%   0.2% 18.6KiB         ring ring_core_0_17_14__x25519_ge_frombytes_vartime
 0.1%   0.2% 18.2KiB   hyper_util hyper_util::client::legacy::client::Client<C,B>::send_request::{{closure}}
 0.1%   0.2% 18.1KiB    [Unknown] fe_loose_invert
 0.1%   0.2% 17.7KiB         prek prek::cli::run::filter::collect_files_from_args::{{closure}}
36.6%  91.6%  8.2MiB              And 19738 smaller methods. Use -n N to show more.
40.0% 100.0%  9.0MiB              .text section size, the file size is 22.4MiB

@j178 j178 force-pushed the lock branch 2 times, most recently from fbfa5ad to 2ee4d52 Compare January 18, 2026 08:02
@j178 j178 marked this pull request as ready for review January 18, 2026 08:09
@j178 j178 requested a review from Copilot January 18, 2026 08:09
@j178 j178 changed the title Show a lock acquire warning if it blocks Show warning if file lock acquiring blocks for long time Jan 18, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements a user-facing warning when acquiring a file lock takes longer than 1 second, addressing issue #1184. The warning helps users understand why the command might appear to be hanging when another prek process is holding the lock.

Changes:

  • Implemented a timeout-based warning mechanism in the lock acquisition logic using tokio::select!
  • Introduced a global reporter infrastructure to allow lock warnings to properly suspend progress bars
  • Converted reporter constructors from From trait implementations to explicit new() methods that set the global reporter

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
crates/prek/src/fs.rs Added timeout logic with warning message when lock acquisition blocks for more than 1 second
crates/prek/src/cli/reporter.rs Added global reporter state and suspend mechanism to allow warnings to be displayed without corrupting progress bars
crates/prek/src/cli/run/run.rs Updated to use new reporter constructor pattern
crates/prek/src/cli/list.rs Updated to use new reporter constructor pattern
crates/prek/src/cli/install.rs Updated to use new reporter constructor pattern
crates/prek/src/cli/auto_update.rs Updated to use new reporter constructor pattern

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@j178 j178 merged commit 4a8b58b into master Jan 18, 2026
19 checks passed
@j178 j178 deleted the lock branch January 18, 2026 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Feedback to user when prek is failing to acquire ~/.cache/prek/lock

2 participants