mysql2 3.19.2-canary.f4ce16ab → 3.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -36,6 +36,7 @@ function encrypt(password, scramble, key) {
36
36
  return crypto.publicEncrypt(
37
37
  {
38
38
  key,
39
+ oaepHash: 'sha1',
39
40
  padding: crypto.constants.RSA_PKCS1_OAEP_PADDING,
40
41
  },
41
42
  stage1
@@ -13,7 +13,13 @@ const STATE_FINAL = -1;
13
13
 
14
14
  function encrypt(password, scramble, key) {
15
15
  const stage1 = xorRotating(Buffer.from(`${password}\0`, 'utf8'), scramble);
16
- return crypto.publicEncrypt(key, stage1);
16
+ return crypto.publicEncrypt(
17
+ {
18
+ key,
19
+ oaepHash: 'sha1',
20
+ },
21
+ stage1
22
+ );
17
23
  }
18
24
 
19
25
  module.exports =
package/lib/base/pool.js CHANGED
@@ -62,7 +62,10 @@ class BasePool extends EventEmitter {
62
62
  if (this._freeConnections.length > 0) {
63
63
  connection = this._freeConnections.pop();
64
64
  this.emit('acquire', connection);
65
- return process.nextTick(() => cb(null, connection));
65
+ return process.nextTick(() => {
66
+ connection._released = false;
67
+ cb(null, connection);
68
+ });
66
69
  }
67
70
  if (
68
71
  this.config.connectionLimit === 0 ||
@@ -126,7 +129,10 @@ class BasePool extends EventEmitter {
126
129
  }
127
130
  } else if (this._connectionQueue.length) {
128
131
  cb = this._connectionQueue.shift();
129
- process.nextTick(cb.bind(null, null, connection));
132
+ process.nextTick(() => {
133
+ connection._released = false;
134
+ cb(null, connection);
135
+ });
130
136
  } else {
131
137
  this._freeConnections.push(connection);
132
138
  this.emit('release', connection);
@@ -6,6 +6,7 @@ class PoolConnection extends Connection {
6
6
  constructor(pool, options) {
7
7
  super(options);
8
8
  this._pool = pool;
9
+ this._released = false;
9
10
  this.lastActiveTime = Date.now();
10
11
  this.once('end', () => {
11
12
  this._removeFromPool();
@@ -16,9 +17,13 @@ class PoolConnection extends Connection {
16
17
  }
17
18
 
18
19
  release() {
20
+ if (this._released) {
21
+ return;
22
+ }
19
23
  if (!this._pool || this._pool._closed) {
20
24
  return;
21
25
  }
26
+ this._released = true;
22
27
  this.lastActiveTime = Date.now();
23
28
  this._pool.releaseConnection(this);
24
29
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mysql2",
3
- "version": "3.19.2-canary.f4ce16ab",
3
+ "version": "3.20.0",
4
4
  "description": "fast mysql driver. Implements core protocol, prepared statements, ssl and compression in native JS",
5
5
  "main": "index.js",
6
6
  "typings": "typings/mysql/index",