NJS-040: connection request timeout #1645

Closed
@todevmilen

Description

I receive this error NJS-040: connection request timeout while the server is running on production. Already check all closed issue regarding this error also read the documentation, but still facing a problem to solve it. Please assist me.
Versions

  • Database: 11g
  • process.platform: linux
  • process.version: v16.14.0
  • process.arch: ' x64 '
  • require('oracledb').versionString: ' 5.1.0 '
  • require('oracledb').oracleClientVersionString: 21.5.0.0.0 '
  • Here is the configuration from which i make a pool. Also before I start the index.js file i set the UV_THREADPOOL_SIZE to 25 (because i have two databases with 10 poolMax set.

    CMD
    
    
    
    
        
     ["sh", "-c", "export UV_THREADPOOL_SIZE=25 && node index.js"]
    module.exports = {
    hrPool: {
       user: process.env.USER_2,
       password: process.env.PASSWORD_2,
       connectString: "local",
       poolMin: 10,
       poolMax: 10,
       poolIncrement: 0,
     hrPoolTest: {
       user: process.env.TEST_NAME,
       password: process.env.TEST_PASS,
       connectString: "test",
       poolMin: 10,
       poolMax: 10,
       poolIncrement: 0,
    

    I can see in the logs that just before this error occurs the incoming request doesn't close the connections.
    Here is example code of the way I create and close connections.

    const oracledb = require("oracledb");
    async function find(selectItemsParams) {
      let conn;
      try {
        conn = await oracledb.getConnection();
        oracledb.outFormat = oracledb.OBJECT;
        const result = await conn.execute(
          `BEGIN example.slc_items ( 
            :p_item_id,
            :p_item_code,
            :info_slc_items
            ); END;`,
            p_item_id: selectItemsParams.p_item_id,
            p_item_code: selectItemsParams.p_item_code,
            info_slc_items: {
              dir: oracledb.BIND_OUT,
              type: oracledb.DB_TYPE_CURSOR,
          { resultSet: true }
        const resultSet = result.outBinds.info_slc_items;
        let row;
        let rows = [];
        while ((row = await resultSet.getRow())) {
          rows.push(row);
        await resultSet.close();
        return rows;
      } catch (err) {
        console.error(err);
        throw err;
      } finally {
        if (conn) {
          // conn assignment worked, need to close
          try {
            await conn.close();
            console.log("connection is closed;");
          } catch (err) {
            console.error(err);
    module.exports.find = find;

    I also can see that the number of active handlers/requests is continuously increasing.