我们在express应用程序中使用sequelize作为ORM。我在生产环境中收到此错误,但无法在本地设置中重现此错误。在生产中,该站点使用 pm2 托管,并且有 4 个工作线程在运行该应用程序。我尝试在本地使用 pm2 运行相同的代码库,但无法重现此问题。
我仅在一个处理 CSV 并将记录保存在数据库中的 API 中遇到此问题。该错误是在为上传 API 提供响应时尝试执行某些查询时引起的。
使用其他 API 运行时 util 函数工作正常。
错误回溯
Error here===> Error: ConnectionManager.getConnection was called after the connection manager was closed!
at ConnectionManager.getConnection (/home/ubuntu/unberry-backend/source/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:113:13)
at /home/ubuntu/unberry-backend/source/node_modules/sequelize/lib/sequelize.js:613:111
at /home/ubuntu/unberry-backend/source/node_modules/retry-as-promised/index.js:70:21
at new Promise (<anonymous>)
at retryAsPromised (/home/ubuntu/unberry-backend/source/node_modules/retry-as-promised/index.js:60:10)
at Sequelize.query (/home/ubuntu/unberry-backend/source/node_modules/sequelize/lib/sequelize.js:606:12)
at PostgresQueryInterface.select (/home/ubuntu/unberry-backend/source/node_modules/sequelize/lib/dialects/abstract/query-interface.js:952:33)
at Function.findAll (/home/ubuntu/unberry-backend/source/node_modules/sequelize/lib/model.js:1753:47)
at processTicksAndRejections (internal/process/task_queues.js:89:5)
at async Function.findOne (/home/ubuntu/unberry-backend/source/node_modules/sequelize/lib/model.js:1917:12)
at async sendInviteToUser (/home/ubuntu/unberry-backend/source/src/services/linkService.js:43:22)
at async uploadUser (/home/ubuntu/unberry-backend/source/src/controllers/linkController.js:67:33)
使用multer进行文件处理。请分享见解!预先感谢。
我也遇到了类似的问题,请问你查出是什么原因了吗?