chore: remove mutex-start log

This commit is contained in:
Adhiraj Singh
2023-01-13 10:20:28 +05:30
parent 5041be776e
commit 5efb0ebbea

View File

@@ -1,7 +1,3 @@
import logger from './logger'
const MUTEX_TIMEOUT_MS = 60_000
export const makeMutex = () => {
let task = Promise.resolve() as Promise<any>
@@ -10,19 +6,12 @@ export const makeMutex = () => {
return {
mutex<T>(code: () => Promise<T> | T): Promise<T> {
task = (async() => {
const stack = new Error('mutex start').stack
let waitOver = false
taskTimeout = setTimeout(() => {
logger.warn({ stack, waitOver }, 'possible mutex deadlock')
}, MUTEX_TIMEOUT_MS)
// wait for the previous task to complete
// if there is an error, we swallow so as to not block the queue
try {
await task
} catch{ }
waitOver = true
try {
// execute the current task
const result = await code()