Skip to content

Commit

Permalink
Merge pull request #991 from forcedotcom/sm/lock-init-no-retries
Browse files Browse the repository at this point in the history
fix: no retries on sync lock
  • Loading branch information
mshanemc authored Nov 15, 2023
2 parents 60bb635 + b7f5588 commit 170213d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/util/fileLocking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { dirname } from 'node:path';
import { lock, lockSync } from 'proper-lockfile';
import { SfError } from '../sfError';
import { Logger } from '../logger/logger';
import { lockRetryOptions } from './lockRetryOptions';
import { lockOptions, lockRetryOptions } from './lockRetryOptions';

type LockInitResponse = { writeAndUnlock: (data: string) => Promise<void>; unlock: () => Promise<void> };
type LockInitSyncResponse = { writeAndUnlock: (data: string) => void; unlock: () => void };
Expand Down Expand Up @@ -74,10 +74,10 @@ export const lockInitSync = (filePath: string): LockInitSyncResponse => {

const [unlock] = fs.existsSync(filePath)
? // if the file exists, wait for it to be unlocked
[lockSync(filePath, lockRetryOptions)]
[lockSync(filePath, lockOptions)]
: // lock the entire directory to keep others from trying to create the file while we are
[
lockSync(dirname(filePath), lockRetryOptions),
lockSync(dirname(filePath), lockOptions),
Logger.childFromRoot('fileLocking.lockInit').debug(
`No file found at ${filePath}. Write will create it. Locking the entire directory until file is written.`
),
Expand Down

0 comments on commit 170213d

Please sign in to comment.