title: node-mysql - when to release connection back into pool
body: <p>I'm using the <a href="https://github.com/felixge/node-mysql" rel="noreferrer"><code>node-mysql</code></a> driver with connection pooling.</p>
  
  <p>Releasing the connection back into the pool when there's only one query, is easy:</p>
  
  <pre><code>pool.getConnection(function(err, connection) {
    if (err) {
      throw err;
    }
  
    query = "SELECT * FROM user WHERE id = ?";
    connection.query(query, [id], function(err, users) {
      connection.release();
  
      if (err) {
        throw err;
      }
  
      // ...
    });
  });
  </code></pre>
  
  <p>What if I need to use the connection a second time? I'd have to move the <code>release()</code> down a few lines. But what happens if the error is thrown? Is the connection never returned to the pool?  </p>
  
  <p>Do I have to use some control flow lib to have a "finally" moment in which I could release it?<br>
  Any better ideas?</p>