当使用 SEAN 堆栈(Sequelize、Express、Angular、Nodejs)开发的 webapp 空闲并且用户在超时后注销时,sequelize/tedious 会抛出以下异常。
任何有关 sequelize 连接池或数据库连接释放标准方式的指针都会有所帮助。
错误是“ 资源当前不属于此池 ”
使用的版本:
乏味的版本 2.0.0
Sequelize 版本 4.1.0
错误:
Unhandled rejection Error: Resource not currently part of this pool
at Pool.destroy (\node_modules\sequelize\node_modules\generic-pool\lib\Pool.js:450:35)
at Connection.<anonymous> (\node_modules\sequelize\lib\dialects\mssql\connection-manager.js:124:25)
at emitOne (events.js:77:13)
at Connection.emit (events.js:169:7)
at Connection.socketError (\node_modules\tedious\lib\connection.js:703:14)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at emitErrorNT (net.js:1257:8)
at doNTCallback2 (node.js:441:9)
at process._tickCallback (node.js:355:17)
最佳答案
我有同样的错误,但它不会导致我的应用程序崩溃。所以我添加了这部分代码来处理它:
const unhandledRejections = new Map();
process.on('unhandledRejection', (reason, p) => {
unhandledRejections.set(p, reason);
});
process.on('rejectionHandled', (p) => {
unhandledRejections.delete(p);
});
希望这会有所帮助...
关于node.js - Sequelize 池相关问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45149511/