mysql2 3.14.5 → 3.14.6-canary.e72247f7

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.
package/lib/base/pool.js CHANGED
@@ -200,7 +200,11 @@ class BasePool extends EventEmitter {
200
200
  Date.now() - this._freeConnections.get(0).lastActiveTime >
201
201
  this.config.idleTimeout)
202
202
  ) {
203
- this._freeConnections.get(0).destroy();
203
+ if (this.config.connectionConfig.gracefulEnd) {
204
+ this._freeConnections.get(0).end();
205
+ } else {
206
+ this._freeConnections.get(0).destroy();
207
+ }
204
208
  }
205
209
  } finally {
206
210
  this._removeIdleTimeoutConnections();
@@ -30,6 +30,13 @@ class BasePoolConnection extends BaseConnection {
30
30
  }
31
31
 
32
32
  end() {
33
+ if (this.config.gracefulEnd) {
34
+ this._removeFromPool();
35
+ super.end();
36
+
37
+ return;
38
+ }
39
+
33
40
  const err = new Error(
34
41
  'Calling conn.end() to release a pooled connection is ' +
35
42
  'deprecated. In next version calling conn.end() will be ' +
@@ -68,6 +68,7 @@ const validOptions = {
68
68
  queueLimit: 1,
69
69
  waitForConnections: 1,
70
70
  jsonStrings: 1,
71
+ gracefulEnd: 1,
71
72
  };
72
73
 
73
74
  class ConnectionConfig {
@@ -190,6 +191,7 @@ class ConnectionConfig {
190
191
  };
191
192
  this.maxPreparedStatements = options.maxPreparedStatements || 16000;
192
193
  this.jsonStrings = options.jsonStrings || false;
194
+ this.gracefulEnd = options.gracefulEnd || false;
193
195
  }
194
196
 
195
197
  static mergeFlags(default_flags, user_flags) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mysql2",
3
- "version": "3.14.5",
3
+ "version": "3.14.6-canary.e72247f7",
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",
@@ -335,6 +335,8 @@ export interface ConnectionOptions {
335
335
  * (Default: false)
336
336
  */
337
337
  jsonStrings?: boolean;
338
+
339
+ gracefulEnd?: boolean;
338
340
  }
339
341
 
340
342
  declare class Connection extends QueryableBase(ExecutableBase(EventEmitter)) {