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

MySQL Connection Timeout (ETIMEDOUT) Causes Crash When DB Becomes Unresponsive #833

Open
bastianmarin opened this issue Mar 4, 2025 · 1 comment

Comments

@bastianmarin
Copy link

Kutt crashes with a connect ETIMEDOUT error when the external MySQL database becomes unresponsive. The server initially starts fine, but if the database stops responding while Kutt is running, the application crashes instead of handling the disconnection gracefully.

Here’s the full error message:

> kutt@3.2.2 start
> node server/server.js --production

> Ready on http://localhost:3100
Connection Error: Error: read ECONNRESET
Connection Error: Error: read ECONNRESET
/home/iroak/Kutt/node_modules/mysql2/lib/base/connection.js:200
    const err = new Error('connect ETIMEDOUT');
                ^

Error: connect ETIMEDOUT
    at Connection._handleTimeoutError (/home/iroak/Kutt/node_modules/mysql2/lib/base/connection.js:200:17)
    at listOnTimeout (node:internal/timers:581:17)
    at process.processTimers (node:internal/timers:519:7) {
  errorno: 'ETIMEDOUT',
  code: 'ETIMEDOUT',
  syscall: 'connect',
  fatal: true
}

Steps to Reproduce

  1. Start Kutt:
    cd /home/iroak/Kutt && npm run start
  2. The server initializes successfully and prints Ready on http://localhost:3100.
  3. While Kutt is running, the external MySQL database temporarily stops responding.
  4. Kutt crashes with the ETIMEDOUT error instead of retrying the connection or handling the failure gracefully.

Expected Behavior

Kutt should handle temporary database disconnections more gracefully, either by retrying the connection or logging an error without crashing.

Actual Behavior

When the external database becomes unresponsive, Kutt crashes with a fatal connect ETIMEDOUT error. This makes it necessary to restart the service manually.

System Info

  • Kutt Version: 3.2.2
  • Node.js Version: 20.18.3
  • Database: External MySQL
  • Operating System: Linux

Additional Context

  • The database sometimes experiences temporary connection issues but eventually recovers.
  • Other applications connected to the same MySQL instance do not crash when the database goes down.
  • The .env file contains the correct database credentials.

Would it be possible to add a reconnection mechanism or error handling to prevent crashes when the database is temporarily unavailable?

@poeti8
Copy link
Member

poeti8 commented Mar 6, 2025

It does retry making a connection again but it exceeds the timeout threshold.

Maybe you can increase timeout:
https://knexjs.org/guide/#acquireconnectiontimeout

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

No branches or pull requests

2 participants