Skip to content

Commit

Permalink
Merge pull request #9 from biothings/fix-896-bte
Browse files Browse the repository at this point in the history
Update retry-staleness dynamics and error handling for locks
  • Loading branch information
tokebe authored Nov 14, 2024
2 parents 0e6cd42 + 489432a commit 038bf8c
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ export function timeoutPromise<T>(promise: Promise<T>, timeout: number): Promise
});
}

export const LOCKFILE_STALENESS = {stale: 5000}; // lock expiration in milliseconds to prevent deadlocks
export const LOCKFILE_STALENESS = {stale: 11000}; // lock expiration in milliseconds to prevent deadlocks
export const LOCKFILE_RETRY_CONFIG = {
retries: {
retries: 10,
retries: 12, // 9.5 seconds max
factor: 2,
minTimeout: 100,
maxTimeout: 1000,
Expand All @@ -108,9 +108,14 @@ export async function lockWithActionAsync<T>(filePaths: string[], action: () =>
return result;
} catch (error) {
debug(`Lockfile error: ${error}`);
// throw error;
throw error;
} finally {
for (const release of releases)
if (release) release();
for (const release of releases) {
try {
if (release) release();
} catch (error) {
debug(`Lockfile release error: ${error}`);
}
}
}
}

0 comments on commit 038bf8c

Please sign in to comment.