🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

mysql-dialect-with-deadlock

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mysql-dialect-with-deadlock

A custom MySQL dialect for [Kysely](https://kysely.dev/) that automatically retries queries when they encounter deadlock errors.

1.1.0
npm
Version published
Weekly downloads
311
-42.73%
Maintainers
1
Weekly downloads
 
Created
Source

MySQL Dialect with Deadlock Retries for Kysely

A custom MySQL dialect for Kysely that automatically retries queries when they encounter deadlock errors.

Features

  • 🔄 Automatic retry of queries that fail due to deadlocks
  • ⚙️ Configurable retry attempts, exponential backoff and delay
  • 📊 Optional retry tracking and logging
  • 🔌 Drop-in replacement for Kysely's standard MySQL dialect

Installation

npm install mysql-dialect-with-deadlock
# or
pnpm add mysql-dialect-with-deadlock

Usage

import { Kysely } from 'kysely'
import { createPool } from 'mysql2'
import { MySQLDialectWithDeadlockRetries } from 'mysql-dialect-with-deadlock'

const db = new Kysely({
  dialect: new MySQLDialectWithDeadlockRetries({
    pool: createPool({
      host: 'localhost',
      user: 'root',
      database: 'test'
    }),
    deadlock: {
      maxAttempts: 3,
      onRetry: (error, attempt) => {
        console.log(`Retry attempt ${attempt} after deadlock: ${error.message}`)
      }
    }
  })
})

Configuration

OptionTypeDefaultDescription
maxAttemptsnumber3Maximum number of retry attempts
delaynumber0Delay in ms between retries
backoffbooleanfalseUse exponential backoff for delays
onRetryfunctionundefinedCallback function called on each retry

License

MIT

FAQs

Package last updated on 14 Apr 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts