Documentation Home
MySQL Connector/Node.js Release Notes
Download these Release Notes
PDF (US Ltr) - 134.5Kb
PDF (A4) - 134.6Kb


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 complement the existing asynchronous mysqlx.getSession(conn_str) method, a new synchronous mysqlx.getClient(conn_str, options) method is added; the new method creates a connection pool handler that provides an asynchronous getSession() method to create and retrieve connections from the pool. Collection pooling options are listed here:

    • enabled: Enables or disables connection pooling; a boolean which defaults to true.

    • maxSize: Maximum number of connections available in the pool; a positive integer which defaults to 25.

    • maxIdleTime: Maximum number of milliseconds a connection can be idle in the queue before being closed; a nonnegative integer which defaults to 0 (infinite).

    • queueTimeout: Maximum number of milliseconds a request waits for a connection to become available; a nonnegative integer which defaults to 0 (infinite).

      This differs from the connectTimeout used when connection pooling is not employed. When a pooling is used, there may already be connections in the pool; queueTimeout controls how long to wait for a connection from the pool.

    Example:

    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 (that is, destroying) the pool effectively closes all server connections. (WL #11831)

  • Added a connection timeout query parameter to both the mysqlx.getClient() (pooling) and mysqlx.getSession() (no pooling) interfaces. This parameter determines the length of time in milliseconds that the client waits for a MySQL server to become available from among the given network addresses. The default value is 10000 (10 seconds). Setting it to 0 disables the timeout so that the client waits until the underlying socket times out. The socket timeout is platform-dependent

    As with other Connector/Node.js parameters, kebab case is used for URI definitions (connection-timeout) and camel case for JavaScript configuration objects (connectionTimeout).

    Example 1:

    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."
        })

    Example 2:

    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.
        });

    When using multiple hosts, the connect-timeout value applies separately to each host. (WL #12197)

Bugs Fixed

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

  • Calling getCollationName() on columns of nontext types such as INT threw 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; each property contains the same value. (Bug #28362115)