From 78483294a1cca9d7507679019555b9775373c7db Mon Sep 17 00:00:00 2001 From: Vitaly Tomilov Date: Fri, 12 Mar 2021 07:36:26 +0000 Subject: [PATCH] make useCount safe --- lib/connect.js | 2 +- package.json | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/connect.js b/lib/connect.js index bccee1769..7162c5b97 100644 --- a/lib/connect.js +++ b/lib/connect.js @@ -37,7 +37,7 @@ function poolConnect(ctx, db, config) { reject(err); } else { if (`$useCount` in client) { - client.$useCount++; + client.$useCount = client.$useCount >= Number.MAX_SAFE_INTEGER ? 0 : ++client.$useCount; } else { Object.defineProperty(client, `$useCount`, { value: 0, diff --git a/package.json b/package.json index be435113a..db3d85920 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pg-promise", - "version": "10.9.4", + "version": "10.9.5", "description": "PostgreSQL interface for Node.js", "main": "lib/index.js", "typings": "typescript/pg-promise.d.ts", @@ -46,7 +46,7 @@ "spex": "3.2.0" }, "devDependencies": { - "@types/node": "14.14.31", + "@types/node": "14.14.33", "bluebird": "3.7.2", "coveralls": "3.1.0", "eslint": "7.21.0", @@ -56,6 +56,6 @@ "JSONStream": "1.3.5", "pg-query-stream": "4.0.0", "tslint": "6.1.3", - "typescript": "4.2.2" + "typescript": "4.2.3" } }