Skip to content

Instantly share code, notes, and snippets.

@StoneyEagle
Created March 20, 2023 17:05
Show Gist options
  • Save StoneyEagle/1cffdbb38d592c8226fc28d8bfcfae9b to your computer and use it in GitHub Desktop.
Save StoneyEagle/1cffdbb38d592c8226fc28d8bfcfae9b to your computer and use it in GitHub Desktop.
Prisma hack to avoid db timeout.
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