Home > @rushstack/node-core-library > LockFile > acquire

LockFile.acquire() method

Attempts to create the lockfile. Will continue to loop at every 100ms until the lock becomes available or the maxWaitMs is surpassed.


static acquire(resourceDir: string, resourceName: string, maxWaitMs?: number): Promise<LockFile>;


Parameter Type Description
resourceDir string  
resourceName string  
maxWaitMs number  




This function is subject to starvation, whereby it does not ensure that the process that has been waiting the longest to acquire the lock will get it first. This means that a process could theoretically wait for the lock forever, while other processes skipped it in line and acquired the lock first.