@rushstack/package-extractor 0.12.9 → 0.12.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.json CHANGED
@@ -1,6 +1,33 @@
1
1
  {
2
2
  "name": "@rushstack/package-extractor",
3
3
  "entries": [
4
+ {
5
+ "version": "0.12.10",
6
+ "tag": "@rushstack/package-extractor_v0.12.10",
7
+ "date": "Tue, 31 Mar 2026 15:14:15 GMT",
8
+ "comments": {
9
+ "dependency": [
10
+ {
11
+ "comment": "Updating dependency \"@rushstack/node-core-library\" to `5.21.0`"
12
+ },
13
+ {
14
+ "comment": "Updating dependency \"@rushstack/terminal\" to `0.22.4`"
15
+ },
16
+ {
17
+ "comment": "Updating dependency \"@rushstack/ts-command-line\" to `5.3.4`"
18
+ },
19
+ {
20
+ "comment": "Updating dependency \"@rushstack/heft-webpack5-plugin\" to `1.3.8`"
21
+ },
22
+ {
23
+ "comment": "Updating dependency \"@rushstack/heft\" to `1.2.8`"
24
+ },
25
+ {
26
+ "comment": "Updating dependency \"@rushstack/webpack-preserve-dynamic-require-plugin\" to `0.12.9`"
27
+ }
28
+ ]
29
+ }
30
+ },
4
31
  {
5
32
  "version": "0.12.9",
6
33
  "tag": "@rushstack/package-extractor_v0.12.9",
package/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
1
  # Change Log - @rushstack/package-extractor
2
2
 
3
- This log was last generated on Wed, 25 Mar 2026 01:00:26 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 31 Mar 2026 15:14:15 GMT and should not be manually modified.
4
+
5
+ ## 0.12.10
6
+ Tue, 31 Mar 2026 15:14:15 GMT
7
+
8
+ _Version update only_
4
9
 
5
10
  ## 0.12.9
6
11
  Wed, 25 Mar 2026 01:00:26 GMT
@@ -58596,9 +58596,12 @@ class LockFile {
58596
58596
  * Attempts to acquire the lock on a Linux or OSX machine
58597
58597
  */
58598
58598
  static _tryAcquireMacOrLinux(resourceFolder, resourceName, pidLockFilePath) {
58599
- let dirtyWhenAcquired = false;
58600
- // get the current process' pid
58599
+ // get the current process identifier (PID)
58601
58600
  const pid = process.pid;
58601
+ // Suppose that a process terminates unexpectedly without deleting its PID-based lockfile,
58602
+ // then we check to see if the process is still alive. The OS may have given the same PID
58603
+ // to a new process, how to detect that? We will rely on getProcessStartTime() which
58604
+ // is stored in the file itself for comparison.
58602
58605
  const startTime = LockFile._getStartTime(pid);
58603
58606
  if (!startTime) {
58604
58607
  throw new Error(`Unable to calculate start time for current process.`);
@@ -58618,17 +58621,23 @@ class LockFile {
58618
58621
  const files = FileSystem_1.FileSystem.readFolderItemNames(resourceFolder);
58619
58622
  // look for anything ending with # then numbers and ".lock"
58620
58623
  const lockFileRegExp = /^(.+)#([0-9]+)\.lock$/;
58624
+ // If we are the process to acquire the lock, it becomes our responsibility to clean up these
58625
+ // stale files. If there is at least 1 stale file, then the resource is assumed to be "dirty"
58626
+ // (for example, the previous process was interrupted before releasing or while acquiring).
58627
+ const staleFilesToDelete = [];
58621
58628
  let match;
58622
58629
  let otherPid;
58623
58630
  for (const fileInFolder of files) {
58624
58631
  if ((match = fileInFolder.match(lockFileRegExp)) &&
58625
58632
  match[1] === resourceName &&
58626
58633
  (otherPid = match[2]) !== pid.toString()) {
58627
- // we found at least one lockfile hanging around that isn't ours
58634
+ // We found at least one lockfile hanging around that isn't ours
58628
58635
  const fileInFolderPath = `${resourceFolder}/${fileInFolder}`;
58629
- dirtyWhenAcquired = true;
58630
58636
  // console.log(`FOUND OTHER LOCKFILE: ${otherPid}`);
58637
+ // Actual start time of the other PID
58631
58638
  const otherPidCurrentStartTime = LockFile._getStartTime(parseInt(otherPid, 10));
58639
+ // The start time from the file, which we will compare with otherPidCurrentStartTime
58640
+ // to determine whether the PID got reused by a new process.
58632
58641
  let otherPidOldStartTime;
58633
58642
  let otherBirthtimeMs;
58634
58643
  try {
@@ -58638,41 +58647,53 @@ class LockFile {
58638
58647
  }
58639
58648
  catch (error) {
58640
58649
  if (FileSystem_1.FileSystem.isNotExistError(error)) {
58641
- // the file is already deleted by other process, skip it
58650
+ // ==> Properly closed lockfile, safe to ignore:
58651
+ // The other process deleted the file, which we assume means it completed successfully,
58652
+ // so the state is not dirty. This is equivalent to if readFolderItemNames() never saw
58653
+ // the file in the firstplace.
58642
58654
  continue;
58643
58655
  }
58644
58656
  }
58645
- // if the otherPidOldStartTime is invalid, then we should look at the timestamp,
58646
- // if this file was created after us, ignore it
58647
- // if it was created within 1 second before us, then it could be good, so we
58648
- // will conservatively fail
58649
- // otherwise it is an old lock file and will be deleted
58650
- if (otherPidOldStartTime === '' && otherBirthtimeMs !== undefined) {
58657
+ // What the other process's file exists, but it is an empty file?
58658
+ // Either they were terminated while acquiring, or else they haven't finished writing it yet.
58659
+ if (otherBirthtimeMs !== undefined && otherPidOldStartTime === '') {
58651
58660
  if (otherBirthtimeMs > currentBirthTimeMs) {
58652
- // ignore this file, he will be unable to get the lock since this process
58653
- // will hold it
58661
+ // ==> Safe to ignore
58662
+ // If the other process was terminated, it happened before they finished acquiring.
58663
+ // If the other process is alive, their file is newer, so we will acquire instead of them.
58654
58664
  // console.log(`Ignoring lock for pid ${otherPid} because its lockfile is newer than ours.`);
58655
58665
  continue;
58656
58666
  }
58657
- else if (otherBirthtimeMs - currentBirthTimeMs < 0 && // it was created before us AND
58667
+ else if (otherBirthtimeMs - currentBirthTimeMs < 0 &&
58658
58668
  otherBirthtimeMs - currentBirthTimeMs > -1000) {
58659
- // it was created less than a second before
58660
- // conservatively be unable to keep the lock
58661
- return undefined;
58669
+ // ==> Race condition
58670
+ // The other process created their file first, so they will probably acquire the lock
58671
+ // after they finish writing the contents. But what if their process is actually dead
58672
+ // and replaced by a new process with the same PID? Normally the otherPidOldStartTime
58673
+ // gives the answer, but in this edge case we are missing that information.
58674
+ // So we conservatively assume that it should not take them more than 1000ms to
58675
+ // open a file, write a PID, and close the file.
58676
+ return undefined; // fail to acquire and retry later
58662
58677
  }
58663
58678
  }
58664
58679
  // console.log(`Other pid ${otherPid} lockfile has start time: "${otherPidOldStartTime}"`);
58665
58680
  // console.log(`Other pid ${otherPid} actually has start time: "${otherPidCurrentStartTime}"`);
58666
- // this means the process is no longer executing, delete the file
58681
+ // Time to compare
58667
58682
  if (!otherPidCurrentStartTime || otherPidOldStartTime !== otherPidCurrentStartTime) {
58683
+ // ==> Stale lockfile
58684
+ // This file doesn't prevent us from acquiring the lock, but it does indicate that
58685
+ // the resource was left in a dirty state. (If we delete the file right now, that
58686
+ // information would be lost, so we clean up later when we acquire successfully.)
58668
58687
  // console.log(`Other pid ${otherPid} is no longer executing!`);
58669
- FileSystem_1.FileSystem.deleteFile(fileInFolderPath);
58688
+ staleFilesToDelete.push(fileInFolderPath);
58670
58689
  continue;
58671
58690
  }
58672
58691
  // console.log(`Pid ${otherPid} lockfile has birth time: ${otherBirthtimeMs}`);
58673
58692
  // console.log(`Pid ${pid} lockfile has birth time: ${currentBirthTimeMs}`);
58674
- // this is a lockfile pointing at something valid
58675
58693
  if (otherBirthtimeMs !== undefined) {
58694
+ // ==> We found a valid file belonging to another process.
58695
+ // With multiple parties trying to acquire, the winner is the smallestBirthTime,
58696
+ // so we need to sort.
58676
58697
  // the other lock file was created before the current earliest lock file
58677
58698
  // or the other lock file was created at the same exact time, but has earlier pid
58678
58699
  // note that it is acceptable to do a direct comparison of the PIDs in this case
@@ -58693,9 +58714,14 @@ class LockFile {
58693
58714
  // we do not have the lock
58694
58715
  return undefined;
58695
58716
  }
58696
- // we have the lock!
58717
+ let dirtyWhenAcquired = false;
58718
+ for (const staleFileToDelete of staleFilesToDelete) {
58719
+ FileSystem_1.FileSystem.deleteFile(staleFileToDelete, { throwIfNotExists: false });
58720
+ dirtyWhenAcquired = true;
58721
+ }
58722
+ // We have the lock!
58697
58723
  lockFile = new LockFile(lockFileHandle, pidLockFilePath, dirtyWhenAcquired);
58698
- lockFileHandle = undefined; // we have handed the descriptor off to the instance
58724
+ lockFileHandle = undefined; // The LockFile object has taken ownership of our handle
58699
58725
  }
58700
58726
  finally {
58701
58727
  if (lockFileHandle) {