ITADN

Network/Mariadb goes down and it causes our node application to crash

#323Closeddylanfvoxtelesys 创建于 2025-07-23
We run a similar setup as below, where if the docker container is stopped instead an error propagating it just crashes the node instance. - I was unable to catch the error unless modifying the Connection class or modifying the Pool connection created to emit/handle errors. - Error was occurring on >= v3, does not occur on v2.5.6 ```js const pool = mariadb.createPool({ dateStrings: true, bigIntAsNumber: true, insertIdAsNumber: true, timezone: 'Z', trace: true, connectionLimit: 10, minimumIdle: 1, idleTimeout: 300, host: 'localhost', user: 'root', password: 'password', port: 3309, database: 'mydatabase, }) pool.on('error', (e) => { console.log(error, e) }) ``` ``` yaml services: mariadb: image: mariadb:10.3.31 container_name: mariadb_server restart: always ports: - "3309:3306" environment: MYSQL_ROOT_PASSWORD: rootpassword MYSQL_DATABASE: mydatabase MYSQL_USER: myuser MYSQL_PASSWORD: mypassword volumes: - mariadb_data:/var/lib/mysql # Persistent storage volumes: mariadb_data: driver: local ``` ``` SqlError: (conn:12, no: 45009, SQLState: 08S01) socket has unexpectedly been closed /node_modules/mariadb/lib/misc/errors.js:90:10 /node_modules/mariadb/lib/connection.js:1518:20 sqlMessage: 'socket has unexpectedly been closed', sql: null, fatal: true, errno: 45009, sqlState: '08S01', code: 'ER_SOCKET_UNEXPECTED_CLOSE' Node.js v22.13.1 [nodemon] app crashed - waiting for file changes before starting... ```
关闭于 2025-10-03 0 条评论