libnpmexec 10.1.8 → 10.1.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.
Files changed (2) hide show
  1. package/lib/with-lock.js +7 -5
  2. package/package.json +5 -5
package/lib/with-lock.js CHANGED
@@ -18,9 +18,10 @@ const { onExit } = require('signal-exit')
18
18
  // - more ergonomic compromised lock handling (i.e. withLock will reject, and callbacks have access to an AbortSignal)
19
19
  // - uses a more recent version of signal-exit
20
20
 
21
+ // mtime precision is platform dependent, so deal in seconds
21
22
  const touchInterval = 1_000
22
- // mtime precision is platform dependent, so use a reasonably large threshold
23
- const staleThreshold = 5_000
23
+ // use a reasonably large threshold, in case stat calls take a while
24
+ const staleThreshold = 60_000
24
25
 
25
26
  // track current locks and their cleanup functions
26
27
  const currentLocks = new Map()
@@ -144,6 +145,7 @@ async function maintainLock (lockPath) {
144
145
  let mtime = Math.round(stats.mtimeMs / 1000)
145
146
  const signal = controller.signal
146
147
 
148
+ let timeout
147
149
  async function touchLock () {
148
150
  try {
149
151
  const currentStats = (await fs.stat(lockPath))
@@ -156,16 +158,16 @@ async function maintainLock (lockPath) {
156
158
  if (currentLocks.has(lockPath)) {
157
159
  await fs.utimes(lockPath, mtime, mtime)
158
160
  }
161
+ timeout = setTimeout(touchLock, touchInterval).unref()
159
162
  } catch (err) {
160
163
  // stats mismatch or other fs error means the lock was compromised
161
164
  controller.abort()
162
165
  }
163
166
  }
164
167
 
165
- const timeout = setInterval(touchLock, touchInterval)
166
- timeout.unref()
168
+ timeout = setTimeout(touchLock, touchInterval).unref()
167
169
  function cleanup () {
168
- clearInterval(timeout)
170
+ clearTimeout(timeout)
169
171
  deleteLock(lockPath)
170
172
  }
171
173
  currentLocks.set(lockPath, cleanup)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "libnpmexec",
3
- "version": "10.1.8",
3
+ "version": "10.1.10",
4
4
  "files": [
5
5
  "bin/",
6
6
  "lib/"
@@ -53,22 +53,22 @@
53
53
  "@npmcli/eslint-config": "^5.0.1",
54
54
  "@npmcli/mock-registry": "^1.0.0",
55
55
  "@npmcli/template-oss": "4.25.1",
56
- "bin-links": "^5.0.0",
56
+ "bin-links": "^6.0.0",
57
57
  "chalk": "^5.2.0",
58
58
  "just-extend": "^6.2.0",
59
59
  "just-safe-set": "^4.2.1",
60
60
  "tap": "^16.3.8"
61
61
  },
62
62
  "dependencies": {
63
- "@npmcli/arborist": "^9.1.6",
63
+ "@npmcli/arborist": "^9.1.8",
64
64
  "@npmcli/package-json": "^7.0.0",
65
65
  "@npmcli/run-script": "^10.0.0",
66
66
  "ci-info": "^4.0.0",
67
67
  "npm-package-arg": "^13.0.0",
68
68
  "pacote": "^21.0.2",
69
- "proc-log": "^5.0.0",
69
+ "proc-log": "^6.0.0",
70
70
  "promise-retry": "^2.0.1",
71
- "read": "^4.0.0",
71
+ "read": "^5.0.1",
72
72
  "semver": "^7.3.7",
73
73
  "signal-exit": "^4.1.0",
74
74
  "walk-up-path": "^4.0.0"