fix(upgrade): handle EPERM in isProcessRunning for cross-user locks#211
Merged
fix(upgrade): handle EPERM in isProcessRunning for cross-user locks#211
Conversation
On Unix, process.kill(pid, 0) throws EPERM when the process exists but is owned by a different user. The previous code treated all errors as 'process not running', which would incorrectly identify an active lock held by another user's process as stale. Now EPERM is handled correctly - if we get EPERM, the process IS running, we just can't signal it.
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨
Bug Fixes 🐛Upgrade
Documentation 📚
🤖 This preview updates automatically when you update the PR. |
Codecov Results 📊✅ Patch coverage is 100.00%. Project has 1959 uncovered lines. Files with missing lines (40)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 76.72% 76.73% +0.01%
==========================================
Files 65 65 —
Lines 8416 8419 +3
Branches 0 0 —
==========================================
+ Hits 6457 6460 +3
- Misses 1959 1959 —
- Partials 0 0 —Generated by Codecov Action |
…ning Adds two tests to cover the EPERM handling fix: - EPERM: returns true (process exists but owned by different user) - ESRCH: returns false (process does not exist) This should improve patch coverage above 80%.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a bug in
isProcessRunningwhere processes owned by a different user were incorrectly identified as not running.On Unix,
process.kill(pid, 0)throws:ESRCH: Process does not exist (not running)EPERM: Process exists but we lack permission to signal it (IS running)The previous code caught all errors and returned
false, which would causehandleExistingLockto incorrectly treat an active lock held by another user's process as stale.Changes
EPERMerror code and returntrue(process is running)falseforESRCHand other errorsTesting