Skip to content

Commit

Permalink
change useCount reset to 1
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaly-t committed Mar 12, 2021
1 parent 7848329 commit 1f6b9e7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ function poolConnect(ctx, db, config) {
reject(err);
} else {
if (`$useCount` in client) {
client.$useCount = client.$useCount >= Number.MAX_SAFE_INTEGER ? 0 : ++client.$useCount;
// Make sure useCount drops to 1, if it ever reaches maximum integer number;
// We do not drop it to zero, to avoid rerun of initialization queries that
// usually check for useCount === 0;
client.$useCount = client.$useCount >= Number.MAX_SAFE_INTEGER ? 1 : ++client.$useCount;
} else {
Object.defineProperty(client, `$useCount`, {
value: 0,
Expand Down

0 comments on commit 1f6b9e7

Please sign in to comment.