Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nitro keeps disconnecting mysql connection #3095

Open
Infam0US92 opened this issue Feb 14, 2025 · 0 comments
Open

Nitro keeps disconnecting mysql connection #3095

Infam0US92 opened this issue Feb 14, 2025 · 0 comments

Comments

@Infam0US92
Copy link

Environment

import { fileURLToPath } from 'url';
import { dirname, resolve } from 'path';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

export default defineNuxtConfig({
  css: [
    '@/assets/css/custom-scrollbar.css'
  ],
  ssr: true,
  app: {
    baseURL: "/",
  },
  compatibilityDate: "2024-11-01",
  devtools: { enabled: true },
  modules: [
    "@nuxtjs/tailwindcss",
    "nuxt-auth-utils",
    "@nuxt/image",
    "@nuxt/icon"
  ],
  nitro: {
    experimental: {
      database: true
    },
    database: {
      default: {
        connector: 'mysql2',
        options: {
          database: process.env.NUXT_MYSQL_DATABASE_NAME,
          user: process.env.NUXT_MYSQL_USER,
          password: process.env.NUXT_MYSQL_PASSWORD,
          host: process.env.NUXT_MYSQL_HOST,
          port: process.env.NUXT_MYSQL_PORT,
          waitForConnections: true,
          connectionLimit: 10,
          queueLimit: 0,
          enableKeepAlive: true,
        }
      }
    },
    storage: {
      db: {
        driver: 'fs',
        base: resolve(__dirname, '.cache/db')
      }
    }
  }
});

Reproduction

I run Nuxt3 in development (or production) mode, some time passes and it loses connection to the database

Describe the bug

I've had a problem with Nuxt3 for some time, or more precisely with Nitro built into it. I'm using the experimental "database" option and I'm using mysql2 as a connector. The problem is that after some time of inactivity on the site, it disconnects the connection to the database and the only thing I have in the logs is this: [nuxt] [request error] [unhandled] [500] Can't add new command when connection is in closed state

Additional context

No response

Logs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants