nodejs-idb-pconnector
nodejs-idb-pconnector copied to clipboard
dbpool failed to detach
Please complete the following information:
- Node.js version: 12.18.4
- idb-connector version: 1.2.9
- idb-pconnector version: 1.0.8
- IBM i version: v7r2 (2 7)
Describe the bug
I have an application and trying to use DBPool to handle any connections. I have created one pool that is used through out the life of the web application. The pool is created when web app is started. Every so often I will get fail to detach error. It doesn't happen everytime. From my understanding when using DBPool i do not need to worry about closing connections. That is handled by the runSql and prepareExecute. Is this not the recommended use for a DBPool?
Database.js
const {DBPool} = require('idb-pconnector');
const pool = new DBPool();
module.exports = pool;
DepartmentJobs.js
'use strict'
const pool = require('./Database');
class DepartmentJobs {
constructor(...) {
...
}
static async get() {
let stmt = "SELECT . . . . . From . . . . ";
try {
const results = await pool.runSql(stmt);
return results;
} catch(error) {
}
}
}
module.exports = DepartmentJobs;
error when running command.
Error: DBPool: Failed to detach()
at DBPool.detach (/webservices/workassist/node_modules/idb-pconnector/lib/dbPool.js:114:22)
Caused By:
Error: DBPoolConnection: failed to detach.
at DBPoolConnection.detach (/webservices/workassist/node_modules/idb-pconnector/lib/dbPoolConnection.js:127:22)
Caused By:
Error: Statement failed to close, new Statement could not be created.
at DBPoolConnection.newStatement (/webservices/workassist/node_modules/idb-pconnector/lib/dbPoolConnection.js:75:24)
Caused By:
Error: SQLSTATE=PAERR SQLCODE=-1 SQLFreeStmt failed.
at /webservices/workassist/node_modules/idb-pconnector/lib/statement.js:77:22
at new Promise (<anonymous>)
at Statement.close (/webservices/workassist/node_modules/idb-pconnector/lib/statement.js:75:12)
at DBPoolConnection.newStatement (/webservices/workassist/node_modules/idb-pconnector/lib/dbPoolConnection.js:73:30)
at DBPoolConnection.detach (/webservices/workassist/node_modules/idb-pconnector/lib/dbPoolConnection.js:123:20)
at DBPool.detach (/webservices/workassist/node_modules/idb-pconnector/lib/dbPool.js:112:24)
at /webservices/workassist/node_modules/idb-pconnector/lib/dbPool.js:210:20
at async DBPool.runSql
To Reproduce Steps to reproduce the behavior: 1. 2. 3. 4.
Expected behavior
I should be able to setup the (global) DBPool and have all connections use this pool. I would assume if a connection is not available then more would be created so there will be no errors. I would not expect a failed to detach error. Is this something i can safely ignore?
Screenshots If applicable, add screenshots to help explain your problem.
Additional context Add any other context about the problem here.