Skip to content

Commit

Permalink
Merge pull request #1074 from jleedev/721
Browse files Browse the repository at this point in the history
Avoid setting numeric config options to NaN
  • Loading branch information
sidorares authored Dec 3, 2019
2 parents 4938577 + 73f13bf commit 890f082
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
9 changes: 6 additions & 3 deletions lib/connection_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ class ConnectionConfig {
this.password = options.password || undefined;
this.passwordSha1 = options.passwordSha1 || undefined;
this.database = options.database;
this.connectTimeout =
options.connectTimeout === undefined ? 10 * 1000 : options.connectTimeout;
this.connectTimeout = isNaN(options.connectTimeout)
? 10 * 1000
: options.connectTimeout;
this.insecureAuth = options.insecureAuth || false;
this.supportBigNumbers = options.supportBigNumbers || false;
this.bigNumberStrings = options.bigNumberStrings || false;
Expand Down Expand Up @@ -153,7 +154,9 @@ class ConnectionConfig {
let flags = 0x0,
i;
if (!Array.isArray(user_flags)) {
user_flags = String(user_flags || '').toUpperCase().split(/\s*,+\s*/);
user_flags = String(user_flags || '')
.toUpperCase()
.split(/\s*,+\s*/);
}
// add default flags unless "blacklisted"
for (i in default_flags) {
Expand Down
12 changes: 6 additions & 6 deletions lib/pool_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ class PoolConfig {
options.waitForConnections === undefined
? true
: Boolean(options.waitForConnections);
this.connectionLimit =
options.connectionLimit === undefined
? 10
: Number(options.connectionLimit);
this.queueLimit =
options.queueLimit === undefined ? 0 : Number(options.queueLimit);
this.connectionLimit = isNaN(options.connectionLimit)
? 10
: Number(options.connectionLimit);
this.queueLimit = isNaN(options.queueLimit)
? 0
: Number(options.queueLimit);
}
}

Expand Down

0 comments on commit 890f082

Please sign in to comment.