Skip to content

Commit 59d7ab2

Browse files
committed
more debugging
1 parent 72e3057 commit 59d7ab2

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

workspaces/libnpmexec/lib/with-lock.js

Lines changed: 6 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,10 +144,15 @@ 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 start = Date.now()
153+
console.log(`fs.stat ${touchCount} start`)
149154
const currentStats = (await fs.stat(lockPath))
155+
console.log(`fs.stat ${touchCount} done in ${Date.now() - start}ms`)
150156
const currentMtime = Math.round(currentStats.mtimeMs / 1000)
151157
if (currentStats.ino !== stats.ino || currentMtime !== mtime) {
152158
throw new Error('Lock compromised')

0 commit comments

Comments
 (0)