Skip to content

Commit f28d48b

Browse files
committed
more debugging
1 parent 72e3057 commit f28d48b

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

workspaces/libnpmexec/lib/with-lock.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable no-console */
12
const fs = require('node:fs/promises')
23
const { rmdirSync } = require('node:fs')
34
const promiseRetry = require('promise-retry')
@@ -143,12 +144,19 @@ async function maintainLock (lockPath) {
143144
// fs.utimes operates on floating points seconds (directly, or via strings/Date objects), which may not match the underlying filesystem's mtime precision, meaning that we might read a slightly different mtime than we write. always round to the nearest second, since all filesystems support at least second precision
144145
let mtime = Math.round(stats.mtimeMs / 1000)
145146
const signal = controller.signal
147+
let touchCount = 0
146148

147149
async function touchLock () {
150+
touchCount++
148151
try {
152+
const currentTouchCount = touchCount
153+
const start = Date.now()
154+
console.log(`${currentTouchCount} fs.stat start`)
149155
const currentStats = (await fs.stat(lockPath))
156+
console.log(`${currentTouchCount} fs.stat done in ${Date.now() - start}ms`)
150157
const currentMtime = Math.round(currentStats.mtimeMs / 1000)
151158
if (currentStats.ino !== stats.ino || currentMtime !== mtime) {
159+
console.log(`${currentTouchCount} expected ${currentStats.ino} === ${stats.ino} and ${currentMtime} === ${mtime}`)
152160
throw new Error('Lock compromised')
153161
}
154162
mtime = Math.round(Date.now() / 1000)

0 commit comments

Comments
 (0)