从今天起,当我尝试使用 knex.js 在本地连接到 postgres 数据库 (v 12) 时,出现以下错误。
Unhandled rejection TimeoutError: Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx) call?
这发生在我已经工作了一年的项目上,没有任何问题。为了解决这个问题,我用一张表创建了一个新数据库。运行以下代码行时,我收到相同的错误:const knex = require('knex');
const db = knex({
client: 'pg',
connection: 'postgresql://postgres:postgres@localhost/a_test',
pool: {
min: 0,
max: 10,
},
});
db.from('test_table')
.select(['id'])
.then(r => {
console.log(r);
});
我不知道什么可能导致这种情况。几周前一切正常,在此期间我没有改变任何东西。我使用 postgresapp 在本地运行 postgres,当我使用 psql
连接到数据库时,一切正常。有什么想法可以解决这个问题吗?
最佳答案
看起来应该使用 Node 14 更新(> 8.0.3)pg 驱动程序版本。 https://github.com/knex/knex/issues/3912
关于node.js - Knex : Timeout acquiring a connection,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62912115/