Repository navigation
fix: throw for a connection string number value that is not a number - #1965
Merged
Merged
Conversation
The connection string library reads a number value with parseInt, so a value such as "abc" gave NaN. For Max Pool Size, Min Pool Size, Packet Size and Connection Timeout, the connect then failed with a misleading error from tarn, the socket or the connect timer. Request Timeout used the default without a warning on tedious and had no timeout on msnodesqlv8. Connection Timeout also had no timeout on msnodesqlv8, and ConnectRetryInterval retried after 1 ms. The parser now throws an error that names the key and the value. The check applies only to the number keys that the parser uses, and only to values that parseInt cannot read, so "30s" still gives 30. An empty value still behaves the same as a left-out key. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
🎉 This PR is included in version 12.8.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this does:
@tediousjs/connection-stringreads a number value withparseInt, so a value such asMax Pool Size=abcgaveNaN. node-mssql passed theNaNon, and the result depended on the key and the driver:Connection TimeoutETIMEOUT Failed to connect to … in NaNmsConnectRetryIntervalMax Pool SizeTarn: opt.max must be an integer > 0Min Pool SizeTarn: opt.min must be an integer >= 0Packet SizeESOCKET … The value of "size" is out of rangeRequest TimeoutThe parser now throws an error that names the key and the value, for example
Invalid value for connection string key "max pool size": "abc" is not a number.parseConnectionString()throws it, and theConnectionPoolconstructor throws it or passes it to the callback.Connection Lifetime,ConnectRetryCount,PoolBlockingPeriod) have no effect in node-mssql, so they don't throw.parseIntcan't read, soConnection Timeout=30sstill gives 30 seconds.Note
A connection string that connected before can now throw, for example
Request Timeout=abcon tedious, or either timeout on msnodesqlv8. Each of these had a value that the driver couldn't use.The new unit tests cover each key, an alias, the constructor, an ignored key and a partial value. The tests for invalid values fail before the change and pass after it. Lint and all 376 unit tests pass. I checked the tedious rows in the table against a local Azure SQL Edge. I got the msnodesqlv8 rows from its source, because msnodesqlv8 can't run on my machine.
Related issues:
Pre/Post merge checklist:
🤖 Generated with Claude Code