typeorm / typeorm

ORM for TypeScript and JavaScript. Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, SAP Hana, WebSQL databases. Works in NodeJS, Browser, Ionic, Cordova and Electron platforms.
http://typeorm.io
MIT License
33.46k stars 6.21k forks source link

QueryFailedError: read ECONNRESET #10872

Closed asijoumi closed 1 week ago

asijoumi commented 2 weeks ago

Issue description

The communication between the server and mysql is reseting

Expected Behavior

Hi !

I have a very strange issue. Sometimes, my connections are reseting. I don't really now if its an typeorm issue or something missing on mysql.

Actual Behavior

QueryFailedError: read ECONNRESET
    at Query.onResult (/usr/src/app/node_modules/typeorm/driver/mysql/MysqlQueryRunner.js:165:37)
    at PoolConnection._notifyError (/usr/src/app/node_modules/mysql2/lib/connection.js:228:21)
    at PoolConnection._handleFatalError (/usr/src/app/node_modules/mysql2/lib/connection.js:183:10)
    at PoolConnection._handleNetworkError (/usr/src/app/node_modules/mysql2/lib/connection.js:196:10)
    at Socket.emit (node:events:517:28)
    at Socket.emit (node:domain:489:12)
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

Steps to reproduce

Don't know

My Environment

Dependency Version
Operating System
Node.js version 18.20.2
Typescript version 5.1.3
TypeORM version 0.3.20

Additional Context

No response

Relevant Database Driver(s)

Are you willing to resolve this issue by submitting a Pull Request?

Yes, I have the time, and I know how to start.

Ginden commented 1 week ago

As you can see in stack trace, it's likely a MySQL issue, not TypeORM one.

I can see few relatively new issues on mysql2 repo, regarding ECONNRESET - https://github.com/sidorares/node-mysql2/issues/2599

Are you using version 3.3.2 or newer of mysql2?

asijoumi commented 1 week ago

Hi @Ginden,

Yes, I searched and I saw that from mysql2.

I'm currently with the version 3.9.5 of mysql.

Maybe should I downgrade it ?

niels-van-den-broeck commented 1 week ago

@asijoumi I created the issue on mysql2, would be nice if you could check if version 3.3.1 of mysql2 still has this issue so we can get some traction over there.

asijoumi commented 1 week ago

@niels-van-den-broeck, I will test it on my dev environment. I will keep you informed as soon as possible.

PS : I don't have this issue for my local environment, only for my dev/staging/prod ...

asijoumi commented 1 week ago

Hi @Ginden, @niels-van-den-broeck,

I have downgraded themysql2 package to version 3.3.1. Since then, over the last 24 hours, I have not encountered the previous error.

Thank you for your help 👍

niels-van-den-broeck commented 1 week ago

Could you comment on the mysql2 issue that you are facing the same issue perhaps? Could help identify the issue

asijoumi commented 1 week ago

Done !

Thank you, I close this issue 👍