Created
March 20, 2023 17:05
-
-
Save StoneyEagle/1cffdbb38d592c8226fc28d8bfcfae9b to your computer and use it in GitHub Desktop.
Prisma hack to avoid db timeout.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const checkDbLock = async () => { | |
const { confDb } = require('./config'); | |
try { | |
await confDb.$queryRaw`BEGIN EXCLUSIVE;`; | |
await confDb.$queryRaw`COMMIT;`; | |
return false; | |
} catch (error) { | |
return true; | |
} | |
}; | |
while (await checkDbLock()) { | |
// | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment