Skip to content

Support AbortController #1758

Open
Open

Description

@verside2

It would be nice if the timeout could be set using an AbortController to unify calls for different versions of Oracle.

await oracledb.getConnection({signal: AbortSignal.timeout(60_000)});

Activity

  1. changed the title [-]Support AbortSignal for timeout[/-] [+]Support AbortController for timeout[/+] on Oct 9, 2025
  2. changed the title [-]Support AbortController for timeout[/-] [+]Support AbortController[/+] on Oct 9, 2025
  3. sharadraju commented on Oct 16, 2025

    @sharadraju
    Member

    Thanks @verside2. We will evaluate this.

  4. sharadraju commented on Dec 9, 2025

    @sharadraju
    Member

    @verside2, can you elaborate a bit more on the use case here.
    How would this be used in an example?

  5. verside2 commented on Dec 15, 2025

    @verside2
    Author

    @verside2, can you elaborate a bit more on the use case here. How would this be used in an example?

    We have a server that monitors the status of over 200 databases. The database versions are different (11.2.0.3.0, 12.1.0.2.0 and 18.0.0.0.0).

    The verification process takes place in two stages:

    1. First, the connection to the database takes place.
    2. Next, a simple query is executed.
    this.#connection = await oracledb.getConnection(this.#dbSettings); // path to sqlnet.ora and instantclient_23_26
    this.#connection.callTimeout = this.#dbReqTimeout;
    
    await this.#connection.execute("select * from mytable");

    The following parameters are specified in the sqlnet.ora file:

    SQLNET.OUTBOUND_CONNECT_TIMEOUT=60
    SQLNET.INBOUND_CONNECT_TIMEOUT=60

    Periodically, in case of network problems, waiting for a connection (stage 1) takes significantly longer than 1 minute. It has not been possible to find out why this happens. It feels like the timeout is either working or not.

    But at the same time, when it comes to stage 2 (query execution), everything works perfectly thanks to the callTimeout setting.

    To solve the problem, we have to do something like this:

    getDbConnection(dbSettings) {
      const {promise, resolve, reject} = Promise.withResolvers();
    
      const timerId = setTimeout(() => reject(new Error("Error message")), Times.MINUTE);
    
      oracledb.getConnection(dbSettings)
      .then(resolve)
      .catch(reject)
      .finally(() => clearTimeout(timerId));
    
      return promise;
    }
    
    ...
    
    this.#connection = await this.getDbConnection(this.#dbSettings); // path to sqlnet.ora and instantclient_23_26
    
    ...
  6. sudarshan12s commented on Feb 9, 2026

    @sudarshan12s
    Member

    HI @verside2 ,
    If you are using pool (createPool), you should have got the following error: NJS-040 If the default queueTimeout should get triggered in latest node-oracledb release 6.10.0.

    NJS-040: connection request timeout. Request exceeded "queueTimeout" of 60000

    If you use standalone, (getConnection ) , Can you share sqlnet trace logs If it is feasible to reproduce : Following are the steps.

    
    # setenv
    ADR_BASE=/tmp/mylogs
    TRACE_LEVEL_CLIENT=16
    
    
    Set `TNS_ADMIN` so that Node can read `$TNS_ADMIN/sqlnet.ora` and run mkdir /tmp/mylogs. Execute the app and  share the logs collected in /tmp/mylogs.
    

    Can you share details of DB, client versions where this issue is seen. Is this only on thick mode?

  7. verside2 commented on Sep 26, 2026

    @verside2
    Author

    Hello! I apologize for the delayed response. What we managed to find out during this time:

    1. Rewriting the code to use a connection pool does not solve the problem. The simplified code now looks like this.

    sqlnet.ora

    SQLNET.OUTBOUND_CONNECT_TIMEOUT = 60
    SQLNET.INBOUND_CONNECT_TIMEOUT = 60

    monitoring.js

    this.#dbSettings = {
      user: xxx,
      password: xxx,
      connectString: `(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=${xxx})(PORT=1521))(CONNECT_DATA=(SID=ORCL)))`,
      poolIncrement: 0,
      poolMax: 1,
      poolMin: 1,
    };
    
    ...
    
    oracledb.initOracleClient({
      configDir: this.#configDir,
      libDir: SETTINGS.instantClientPath,
    });
    
    ...
    
    console.log("start base connect");
    
    this.#connection = await this.getDbConnection(); // see below
    this.#connection.callTimeout = this.#dbReqTimeout; // 60 seconds
    
    console.log("start base execute");
    
    await this.#connection.execute("select * from mytable");
    
    ...
    
    async getDbConnection() {
      const pool = await oracledb.createPool(this.#dbSettings);
    
      this.#connectionPool = pool;
    
      return pool.getConnection();
    }
    
    ...
    1. The log of the freeze is attached (unfortunately, writing a clean log is problematic, as connections to several databases may be checked simultaneously. At the moment, there is only one suitable example with a detailed log).

    Summary:

    "27.08.2026, 03:25:36","t-nnov-01-l working","start base connect"
    "27.08.2026, 03:29:07","t-nnov-01-l working","start base execute"
    
    I:2026-08-27 03:25:36.345474 : nsbasic_brc:entry: oln/tot=0,prd=0
    I:2026-08-27 03:25:36.345481 : nsbasic_brc:connection_id = WfpngF+ENpzgYwEBAH/16g==
    S:2026-08-27 03:25:36.345488 : nttfprd:entry
    I:2026-08-27 03:29:07.816330 : nttfprd:socket 29 had bytes read=1308
    S:2026-08-27 03:29:07.816410 : nttfprd:exit
    I:2026-08-27 03:29:07.816422 : nsbasic_brc:type=6, plen=2520
    I:2026-08-27 03:29:07.816431 : nsbasic_brc:what=1, tot =1308
    S:2026-08-27 03:29:07.816442 : nttfprd:entry
    I:2026-08-27 03:29:07.818392 : nttfprd:socket 29 had bytes read=1212
    S:2026-08-27 03:29:07.818417 : nttfprd:exit
    
    1. Adding the SQLNET.RECV_TIMEOUT = 60 parameter to the sqlnet.ora file seems to solve the problem. Without this, no other timeouts help.

    System info at this time:
    Ubuntu 24.04.5 (and 26.04.1)
    nodejs 24.21.0
    oracle instant client (basic lite package zip) 23.26.3.0.0
    oracledb 7.0.1
    Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production (for the example provided in the log)

    ora_145052_131725593056960.trc.log

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions