Uploaded image for project: 'MariaDB Connector/node.js'
  1. MariaDB Connector/node.js
  2. CONJS-242

mariadb.createPool: UncaughtException error

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Minor
    • Resolution: Duplicate
    • 3.1.0
    • 3.1.1
    • pool

    Description

      If Node w/mariadb connector & mariadb server losses connection between them, an 'UncaughtException' error will happen. Maybe I'm too new at this, but it seems like there might be an error in the createPool. Desire is to catch the error and let the pool try to reconnect in X time.

      Assuming "ClientOptions" are valid and MariaDB server is running, the following will create a pool in Node.js:
      const pool = mariadb.createPool(clientOptions)

      That is working, but if I simulate that the MariaDB server dies/losing connection (i.e. stops the docker container):
      Node will crash after a few seconds with an 'UncaughtException' error.
      Seems like createPool is not a promise itself, but it's service is. So not sure how to catch the error and let it try to connect again in X time.

      I have tried to listen to events:

      • pool.on('error' ... This gives a error message 'ECONNREFUSED'
      • process.on('uncaughtException' ... This gives a error message 'ECONNREFUSED'
        In both cases Node.js exits, and there seems no possible way to recover from this (beside PM2 or forever; not tested these)

      Detailed error message:
      node:internal/process/promises:289
      triggerUncaughtException(err, true /* fromPromise */);

      Error: connect ECONNREFUSED ::1:3306
      at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1494:16)
      From event:
      at D:\Code\node-db-boilerplate\node_modules\mariadb\lib\connection.js:133:13
      at new Promise (<anonymous>)
      at Connection.connect (D:\Code\node-db-boilerplate\node_modules\mariadb\lib\connection.js:121:12)
      at Pool._createConnection (D:\Code\node-db-boilerplate\node_modules\mariadb\lib\pool.js:402:16)
      at Pool._doCreateConnection (D:\Code\node-db-boilerplate\node_modules\mariadb\lib\pool.js:40:10)
      at listOnTimeout (node:internal/timers:568:17)
      at process.processTimers (node:internal/timers:511:7)
      Emitted 'error' event on PoolPromise instance at:
      at Pool.emit (node:events:512:28)
      at D:\Code\node-db-boilerplate\node_modules\mariadb\lib\pool.js:258:22
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

      { errno: -4078, code: 'ECONNREFUSED', syscall: 'connect', address: '::1', port: 3306, fatal: true, sqlState: 'HY000' }

      Attachments

        Activity

          People

            diego dupin Diego Dupin
            rinoJira Rino Rabe
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.