Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: no retries on sync lock #991

Merged
merged 1 commit into from
Nov 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading