Documentation Home
MySQL Connector/Node.js Release Notes
Download these Release Notes
PDF (US Ltr) - 92.8Kb
PDF (A4) - 93.6Kb
HTML Download (TGZ) - 27.8Kb
HTML Download (Zip) - 55.3Kb


MySQL Connector/Node.js Release Notes  /  Changes in MySQL Connector/Node.js 8.0  /  Changes in MySQL Connector/Node.js 8.0.13 (2018-10-22, General Availability)

Changes in MySQL Connector/Node.js 8.0.13 (2018-10-22, General Availability)

Functionality Added or Changed

  • To go with the existing asynchronous mysqlx.getSession(conn_str) method, a new synchronous mysqlx.getClient(conn_str, options) method was added that creates a connection pool handler that provides an asynchronous getSession() method to create and retrieve connections from the pool. The collection pooling options are:

    • enabled: enables or disables connection pooling; boolean and defaults to true.

    • maxSize: maximum number of connections available in the pool; positive integer and defaults to 25.

    • maxIdleTime: maximum number of milliseconds a connection can be idle in the queue before being closed; integer >= 0 and defaults to 0 (infinite).

    • queueTimeout: maximum number of milliseconds a request will wait for a connection to become available; integer >= 0 and defaults to 0 (infinite).

      This is different than connectTimeout that's used for non-pooling. In a pooling scenario, there might already be connections in the pool and queueTimeout controls how long to wait for a connection in the pool.

    Example usage:

    var mysqlx = require('@mysql/xdevapi')
    var client = mysqlx.getClient(
      { user: 'root', host: 'localhost', port: 33060 }, 
      { pooling: { enabled: true, maxIdleTime: 5000, maxSize: 25, queueTimeout: 20000 } }
    );
    
    client.getSession()
      .then(session => {
        console.log(session.inspect())
        return session.close() // the connection becomes idle in the client pool
      })
      .then(() => {
        return client.getSession()
      })
      .then(session => {
        console.log(session.inspect())
        return client.close() // closes all connections and destroys the pool
      })

    Closing a session attached to the pool makes the connection available in the pool for subsequent getSession() calls, while closing (destroying) the pool effectively closes all server connections.

  • Added a connection timeout query parameter. This defines the length of time (milliseconds) the client waits for a MySQL server to become available in the given network addresses. It was added to both the mysqlx.getSession() (non-pooling sessions) and mysqlx.getClient() (pooling sessions) interfaces. This option defaults to 10000 (10 seconds). The value 0 disables the timeout so the client will wait until the underlying socket (platform dependent) times out.

    Similar to other option formatting rules, this option defined as connection-timeout (kabab-style) for URI definitions and connectionTimeout (camelCase) for plain JavaScript configuration objects.

    Example usage:

    const mysqlx = require('@mysql/xdevapi');
    var client = mysqlx.getClient('root@localhost?connect-timeout=5000')
    client.getSession()
        .catch(err => {
            console.log(err.message) // "Connection attempt to the server was aborted. Timeout of 5000 ms was exceeded."
        })
    
    // Or
    
    const mysqlx = require('@mysql/xdevapi');
    var client = mysqlx.getClient('mysqlx://root:passwd@[localhost:33060, 127.0.0.1:33060]?connect-timeout=5000')
    client.getSession()
        .catch(err => {
            // connection could not be established after 10 seconds (5 seconds for each server)
            console.log(err.message); // All server connection attempts were aborted. Timeout of 5000 ms was exceeded for each selected server.
        });

    In a multi-host scenario, the connect-timeout value applies to each individual host.

Bugs Fixed

  • Improved the handling of X Protocol global notices by properly logging and then ignoring non-fatal errors, and making the connection unusable for subsequent operations in the case of a fatal error. (Bug #28653781)

  • Calling getCollationName() on non-textual fields, such as INT, threw the following error "TypeError: Cannot read property 'collation' of undefined". (Bug #28608923)

  • The fields() method did not function with valid expressions generated by the expr() method. (Bug #28409639)

  • The returned Session.inspect() object now includes the 'user' property in addition to the 'dbUser' property but containing the same value. (Bug #28362115)