Tony133 / nestjs-mysql

Mysql module for Nest framework (node.js) 😻
MIT License
14 stars 3 forks source link

[Nest] 30 - 04/14/2024, 4:54:00 AM ERROR [ExceptionsHandler] Can't add new command when connection is in closed state Error: Can't add new command when connection is in closed state #675

Open OnZeng opened 5 months ago

OnZeng commented 5 months ago

[Nest] 30 - 04/14/2024, 4:54:00 AM ERROR [ExceptionsHandler] Can't add new command when connection is in closed state Error: Can't add new command when connection is in closed state Errors are reported automatically at regular intervals

Tony133 commented 5 months ago

Reading this issue: https://github.com/sidorares/node-mysql2/issues/1898 is a problem with the mysql2 package

OnZeng commented 5 months ago

I'm still not gonna fix it,

eadcaea774f63913514a0a77ac0d9e7

我应该怎么修复这个错误

Tony133 commented 5 months ago

mmmh what version of the package are you using the latest 0.0.13? try to install nest-mysql version 0.0.12 maybe the problem was introduced with mysql v3.9.4, in version 0.0.12 there should be version 3.9.1 of the mysql2 package

OnZeng commented 5 months ago

nest-mysql is 0.0.13 mysql2 is 3.9.3

Tony133 commented 5 months ago

nest-mysql is 0.0.13 mysql2 is 3.9.3

try using these versions here:

OnZeng commented 5 months ago

I've switched versions I'll run some tests. Wait for my results

OnZeng commented 5 months ago

The same mistakes happen The problem has not been solved How do I create a connection pool to connect to the database

Tony133 commented 5 months ago

The same mistakes happen The problem has not been solved How do I create a connection pool to connect to the database

Okay, I released a new version 0.0.14 to make pool connections try doing that:

MysqlModule.forRoot({
    host: 'localhost',
    database: 'test2',
    password: 'root',
    user: 'root',
    port: 3306,  
    waitForConnections: true,
    connectionLimit: 10,
    queueLimit: 0,
    pool: true,
}),

put the flag "pool:true" in the configuration, so it does the switch for the connection pool, let me know if it works

OnZeng commented 5 months ago

非常棒,我去实验一下,看看问题有没有被解决,可能会晚点回复你结果