Через секунд 40 происходит разрыв соединения и выводит ошибку
(node:10832) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
events.js:183
throw er; // Unhandled 'error' event
^
Error: Connection lost: The server closed the connection.
at Protocol.end (C:\Users\sskat\Desktop\project\node_modules\mysql\lib\protocol\Protocol.js:113:13)
at Socket.<anonymous> (C:\Users\sskat\Desktop\project\node_modules\mysql\lib\Connection.js:109:28)
at emitNone (events.js:111:20)
at Socket.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1055:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
Вот сам файл
const
mysql = require('mysql'),
{ error } = require('handy-log'),
{ MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE } = process.env
const db = mysql.createConnection({
host: MYSQL_HOST,
user: MYSQL_USER,
password: MYSQL_PASSWORD,
database: MYSQL_DATABASE,
charset: 'utf8mb4'
})
db.connect(err => {
if(err){
error(err.message)
}
})
module.exports = db