-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
feat(sap): use the native driver for connection pooling #11520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThis change removes the dependency on the Changes
Sequence Diagram(s)sequenceDiagram
participant App
participant SapDriver
participant HanaClientPool
App->>SapDriver: connect()
SapDriver->>HanaClientPool: createPool(connectionOptions, poolOptions)
SapDriver-->>App: connection ready
App->>SapDriver: obtainMasterConnection()
SapDriver->>HanaClientPool: getConnection()
HanaClientPool-->>SapDriver: connection
SapDriver-->>App: connection
App->>SapDriver: disconnect()
SapDriver->>HanaClientPool: clear()
HanaClientPool-->>SapDriver: pool cleared
SapDriver-->>App: disconnected
Possibly related PRs
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
npm error Exit handler never called! 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (2)
🧰 Additional context used🧬 Code Graph Analysis (1)src/driver/sap/SapDriver.ts (2)
⏰ Context from checks skipped due to timeout of 90000ms (20)
🔇 Additional comments (15)
|
commit: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 5
🧹 Nitpick comments (4)
test/functional/driver/mysql/connection-options/enable-query-timeout.ts (1)
11-11: Trim the trailing space in the suite description.
The extra whitespace at the end of the description string is easy to overlook but will show up in reporter output.-describe("driver > mysql > connection options > enableQueryTimeout ", () => { +describe("driver > mysql > connection options > enableQueryTimeout", () => {sample/playground/package.json (1)
15-15: Avoid using"*"for the TypeORM dependency in the playground.
A wildcard can unintentionally pull in future major versions with breaking changes and make reproducing issues harder. Pin to the current major (or use a caret) just like the rest of the repo.- "typeorm": "*" + "typeorm": "^0.3.24"test/functional/driver/sap/connection-pool.ts (1)
28-34: Guard against slow DB start-up – bump Mocha timeoutSAP HANA spin-up / pool allocation routinely exceeds the default 2 s Mocha timeout on CI.
Add an explicit timeout to avoid flaky “timeout of 2000 ms exceeded” failures:- it("should be managed correctly", () => - Promise.all( + it("should be managed correctly", async function () { + this.timeout(15000); // give HANA some breathing room + await Promise.all((Keep the body identical; just wrap it in an
async functionand set the timeout.)src/driver/sap/SapQueryRunner.ts (1)
308-309: Suppress errors when dropping a prepared statement
statement.drop()is best-effort clean-up; on some drivers it throws
ERR_INVALID_STMT. Wrap it to ensure thefinallyblock never re-throws.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
package-lock.jsonis excluded by!**/package-lock.jsonsample/playground/package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (14)
README-zh_CN.md(0 hunks)README.md(0 hunks)README_ko.md(0 hunks)docs/docs/getting-started.md(0 hunks)package.json(2 hunks)sample/playground/package.json(1 hunks)src/driver/sap/SapConnectionOptions.ts(2 hunks)src/driver/sap/SapDriver.ts(5 hunks)src/driver/sap/SapQueryRunner.ts(5 hunks)src/platform/PlatformTools.ts(0 hunks)test/functional/driver/mysql/connection-options/enable-query-timeout.ts(1 hunks)test/functional/driver/postgres/connection-options.ts(2 hunks)test/functional/driver/sap/connection-pool.ts(1 hunks)test/functional/query-builder/convert-to-entity/convert-to-entity.ts(1 hunks)
💤 Files with no reviewable changes (5)
- README_ko.md
- docs/docs/getting-started.md
- README.md
- src/platform/PlatformTools.ts
- README-zh_CN.md
🧰 Additional context used
🧬 Code Graph Analysis (3)
test/functional/driver/sap/connection-pool.ts (2)
test/utils/test-utils.ts (3)
createTestingConnections(388-482)reloadTestingDatabases(500-505)closeTestingConnections(487-495)src/driver/sap/SapDriver.ts (1)
SapDriver(35-861)
src/driver/sap/SapQueryRunner.ts (7)
src/error/QueryFailedError.ts (1)
QueryFailedError(7-32)src/driver/postgres/PostgresQueryRunner.ts (2)
stream(334-352)query(238-329)src/driver/mongodb/MongoQueryRunner.ts (2)
stream(592-601)query(571-575)src/driver/oracle/OracleQueryRunner.ts (2)
stream(308-351)query(193-303)src/driver/sqlserver/SqlServerQueryRunner.ts (2)
stream(337-396)query(203-332)src/driver/sqlite-abstract/AbstractSqliteQueryRunner.ts (1)
stream(167-174)src/driver/aurora-mysql/AuroraMysqlQueryRunner.ts (2)
stream(189-208)query(158-184)
src/driver/sap/SapDriver.ts (2)
src/error/TypeORMError.ts (1)
TypeORMError(1-17)src/platform/PlatformTools.ts (1)
PlatformTools(17-279)
⏰ Context from checks skipped due to timeout of 90000ms (19)
- GitHub Check: database-tests (18) / mysql_mariadb
- GitHub Check: database-tests (18) / better-sqlite3
- GitHub Check: database-tests (18) / cockroachdb
- GitHub Check: database-tests (16) / cockroachdb
- GitHub Check: database-tests (16) / sqlite
- GitHub Check: database-tests (16) / better-sqlite3
- GitHub Check: database-tests (16) / sqljs
- GitHub Check: database-tests (16) / postgres (17-3.5)
- GitHub Check: database-tests (16) / postgres (14-3.5)
- GitHub Check: database-tests (16) / mysql_mariadb
- GitHub Check: database-tests (16) / mssql (^11.0.1)
- GitHub Check: database-tests (16) / mssql (^9.1.1)
- GitHub Check: database-tests (16) / mssql (^10.0.1)
- GitHub Check: database-tests (16) / mongodb
- GitHub Check: database-tests-windows / better-sqlite3
- GitHub Check: database-tests-windows / sqlite
- GitHub Check: database-tests-windows / sqljs
- GitHub Check: formatting
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (12)
test/functional/query-builder/convert-to-entity/convert-to-entity.ts (1)
11-11: Suite name change is clear & consistent – looks good.
No further action required.test/functional/driver/postgres/connection-options.ts (1)
10-10: Renamed titles improve clarity – good change.
The updated wording better matches the hierarchy used in other driver tests.Also applies to: 24-24
package.json (1)
111-112:Details
❌ Incorrect review comment
Confirm intended
@sap/hana-clientversion ranges.
devDependenciesnow require^2.23.27whilepeerDependenciesallow^2.14.22. Having the dev range higher than (and partially outside) the peer range is unusual and may cause duplicate copies or peer-dep warnings for consumers. Verify this split is deliberate; otherwise align the ranges.Also applies to: 166-168
🏁 Script executed:
#!/bin/bash # Show the latest published versions and verify the chosen tags. npm view @sap/hana-client version time --json | jq 'to_entries | .[-5:]'Length of output: 4303
🏁 Script executed:
#!/bin/bash # Show all occurrences of @sap/hana-client in package.json with context rg -n -C3 '@sap/hana-client' package.jsonLength of output: 720
Peer and Dev dependency ranges are aligned
ThedevDependenciesrange^2.23.27(>=2.23.27 <3.0.0) is fully contained within thepeerDependenciesrange^2.14.22(>=2.14.22 <3.0.0), so there’s no mismatch or risk of duplicate installs or peer‐dependency warnings. No changes required.
- package.json: lines 111–112, 166–168
Likely an incorrect or invalid review comment.
test/functional/driver/sap/connection-pool.ts (1)
46-58: Re-using aQueryRunnerafter a failedconnect()may be fragile
newQueryRunner.connect()is first expected to reject, and then called again after a release.
If the first failure leaves internal state (e.g.isReleased,connectionundefined but flagged), a secondconnect()could still reject on some drivers.Safer pattern:
- const newQueryRunner = await dataSource.createQueryRunner() + const newQueryRunner = await dataSource.createQueryRunner() await expect(newQueryRunner.connect()).to.be.rejectedWith( "Unable to create connection, the maxConnectedOrPool limit has been reached", ) const oldQueryRunner = queryRunners.pop()! await oldQueryRunner.release() - queryRunners.push(newQueryRunner) - await expect(newQueryRunner.connect()).to.be.fulfilled + const retryRunner = await dataSource.createQueryRunner() + queryRunners.push(retryRunner) + await expect(retryRunner.connect()).to.be.fulfilledThis eliminates any reliance on driver behaviour after a rejected
connect().src/driver/sap/SapQueryRunner.ts (1)
271-287: Handle empty result when queryingCURRENT_IDENTITY_VALUE()If the insert happened into a table without an identity column (or the driver
returns[]),identityValueResult[0]throws. Returnundefined(or keep
raw) instead of crashing.- result.raw = - identityValueResult[0]["CURRENT_IDENTITY_VALUE()"] - result.records = identityValueResult + if (identityValueResult.length) { + result.raw = + identityValueResult[0]["CURRENT_IDENTITY_VALUE()"] + } + result.records = identityValueResultsrc/driver/sap/SapConnectionOptions.ts (4)
22-22: Documentation accurately reflects the new default driver.The comment correctly indicates that the default driver is now
@sap/hana-clientinstead of the deprecatedhdb-pool.
27-28: Proper deprecation notice with clear migration path.The deprecation notice correctly directs users to use the
driverproperty instead.
35-59: Well-documented pool configuration options.The new pool options are clearly documented with appropriate descriptions and default values that align with the native SAP HANA client pooling capabilities.
62-63: Clear deprecation notices with appropriate guidance.The deprecation notices effectively communicate:
- Migration paths where alternatives exist
- Clear indication when options are obsolete
- Important unit conversion information (milliseconds to seconds for timeout values)
Also applies to: 73-74, 79-80, 85-86, 91-92
src/driver/sap/SapDriver.ts (3)
1-1: Correct import for promisifying callback-based APIs.The
promisifyimport from Node.js built-inutilmodule is appropriate for converting callback-based SAP HANA client methods to promises.
248-266: Clean connection options setup with proper undefined handling.The code correctly builds connection options, removes undefined values, and merges extra options using appropriate nullish coalescing.
830-849: Well-structured dependency loading with proper fallback handling.The code correctly:
- Prioritizes explicitly provided drivers using nullish coalescing
- Maintains backward compatibility with deprecated
hanaClientDriver- Uses early return pattern for better readability
- Provides appropriate error handling
60ca58e to
f7bd211
Compare
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (4)
test/functional/driver/sap/connection-pool.ts (1)
32-34: Unsupported Chai chain – replacelessThanOrEqualwithat.mostSame issue noted previously; the assertion throws at runtime.
- expect(poolClient.getPooledCount()).to.be.lessThanOrEqual(3) + expect(poolClient.getPooledCount()).to.be.at.most(3)src/driver/sap/SapQueryRunner.ts (2)
88-95: Wrap disconnect in try/catch to handle errors gracefully.
362-377: Critical: Bind cleanup to all terminating events to prevent lock leaks.src/driver/sap/SapDriver.ts (1)
316-324: Disconnect method properly handles pool cleanup.The method correctly throws an error when the pool is not set and uses promisified clear() for async cleanup. The implementation follows the pattern used in other database drivers.
🧹 Nitpick comments (5)
src/driver/mongodb/MongoDriver.ts (1)
267-271: Consider awaiting the connection close for graceful shutdown
this.queryRunner.databaseConnection.close()is invoked withoutawait. If the underlying driver returns a promise (Mongo v4+ does), the disconnect procedure will finish before the connection is actually closed, which can surface as flakiness in integration tests or during process shutdown.- this.queryRunner.databaseConnection.close() + await this.queryRunner.databaseConnection.close()sample/playground/package.json (1)
18-21: Version drift checkThe dev-dependency bump/downgrade looks harmless, but make sure the new
typescript(5.8) and the older@types/node(20.19) combo compiles the whole repo.
If CI already covers this, feel free to ignore.docs/docs/getting-started.md (2)
223-226: Malformed inline-code fence – backtick is never closedThe SAP Hana install command spans two lines which leaves
the opening back-tick unterminated and renders the remainder of
the file in a code font.- `npm install @sap/hana-client --save - ` + `npm install @sap/hana-client --save`
228-231: Keep formatting consistent across driver sectionsA couple of earlier driver bullets still use a fenced code block
while Spanner / SAP now rely on inline snippets. Consider aligning
all driver install instructions on one style (inline back-ticks
work well and keep the list compact).docs/docs/data-source/2-data-source-options.md (1)
543-556: SAP section is missing option details & has punctuation glitches
sslValidateCertificateshould be wrapped in back-ticks (like the other keys)- “For example, true.” – the comma after example is a stray punctuation mark.
- The new pooling keys introduced in the code (
maxConnectedOrPooled,
maxPooledIdleTime,pingCheck,poolCapacity) are not documented;
users will look for them here.- - `sslValidateCertificate` - Whether to validate the SSL certificate. For example, true. + - `sslValidateCertificate` - Whether to validate the SSL certificate. For example, `true`. + +### Pool options + +```text +pool: { + maxConnectedOrPooled?: number // maximum total connections (in-use + idle) + maxPooledIdleTime?: number // ms before an idle connection is closed + pingCheck?: boolean // validate idle connections with a ping + poolCapacity?: number // hard upper limit maintained by driver +} +```🧰 Tools
🪛 LanguageTool
[uncategorized] ~552-~552: Loose punctuation mark.
Context: ...ertificate. For example, true. -key,certandcafor the encrypted conne...(UNLIKELY_OPENING_PUNCTUATION)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
package-lock.jsonis excluded by!**/package-lock.jsonsample/playground/package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (21)
README-zh_CN.md(0 hunks)README.md(0 hunks)README_ko.md(0 hunks)docs/docs/data-source/2-data-source-options.md(1 hunks)docs/docs/getting-started.md(1 hunks)package.json(2 hunks)sample/playground/package.json(1 hunks)src/driver/cockroachdb/CockroachDriver.ts(1 hunks)src/driver/mongodb/MongoDriver.ts(1 hunks)src/driver/mysql/MysqlDriver.ts(1 hunks)src/driver/oracle/OracleDriver.ts(1 hunks)src/driver/postgres/PostgresDriver.ts(1 hunks)src/driver/sap/SapConnectionOptions.ts(2 hunks)src/driver/sap/SapDriver.ts(5 hunks)src/driver/sap/SapQueryRunner.ts(5 hunks)src/driver/sqlserver/SqlServerDriver.ts(1 hunks)src/platform/PlatformTools.ts(0 hunks)test/functional/driver/mysql/connection-options/enable-query-timeout.ts(1 hunks)test/functional/driver/postgres/connection-options.ts(2 hunks)test/functional/driver/sap/connection-pool.ts(1 hunks)test/functional/query-builder/convert-to-entity/convert-to-entity.ts(1 hunks)
💤 Files with no reviewable changes (4)
- README.md
- README_ko.md
- src/platform/PlatformTools.ts
- README-zh_CN.md
🧰 Additional context used
🧬 Code Graph Analysis (8)
src/driver/mongodb/MongoDriver.ts (1)
src/error/ConnectionIsNotSetError.ts (1)
ConnectionIsNotSetError(6-12)
src/driver/oracle/OracleDriver.ts (1)
src/error/ConnectionIsNotSetError.ts (1)
ConnectionIsNotSetError(6-12)
src/driver/sqlserver/SqlServerDriver.ts (1)
src/error/ConnectionIsNotSetError.ts (1)
ConnectionIsNotSetError(6-12)
src/driver/postgres/PostgresDriver.ts (1)
src/error/ConnectionIsNotSetError.ts (1)
ConnectionIsNotSetError(6-12)
src/driver/mysql/MysqlDriver.ts (1)
src/error/ConnectionIsNotSetError.ts (1)
ConnectionIsNotSetError(6-12)
src/driver/cockroachdb/CockroachDriver.ts (1)
src/error/ConnectionIsNotSetError.ts (1)
ConnectionIsNotSetError(6-12)
src/driver/sap/SapQueryRunner.ts (1)
src/error/QueryFailedError.ts (1)
QueryFailedError(7-32)
src/driver/sap/SapDriver.ts (3)
src/error/ConnectionIsNotSetError.ts (1)
ConnectionIsNotSetError(6-12)src/error/TypeORMError.ts (1)
TypeORMError(1-17)src/platform/PlatformTools.ts (1)
PlatformTools(17-279)
🪛 LanguageTool
docs/docs/data-source/2-data-source-options.md
[uncategorized] ~552-~552: Loose punctuation mark.
Context: ...ertificate. For example, true. - key, cert and ca for the encrypted conne...
(UNLIKELY_OPENING_PUNCTUATION)
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: database-tests (20) / cockroachdb
- GitHub Check: database-tests (16) / cockroachdb
- GitHub Check: database-tests (18) / cockroachdb
- GitHub Check: database-tests-windows / better-sqlite3
🔇 Additional comments (23)
src/driver/mongodb/MongoDriver.ts (1)
263-266: Standardised early-throw looks goodSwitching from
Promise.rejectto a synchronousthrowinside anasyncmethod keeps the observable behaviour (the returned promise is still rejected) while simplifying the code – consistent with the other drivers updated in this PR.sample/playground/package.json (1)
15-15: Using"typeorm": "*"can break the example app unpredictablyThe wildcard installs whatever is latest on npm at runtime, which might be a future incompatible major version or a pre-release. Pin to the current repo’s version (e.g.
"workspace:*"if you rely on the monorepo, or"0.4.x"with a caret) to keep the sample reproducible.- "typeorm": "*" + "typeorm": "workspace:*"src/driver/mysql/MysqlDriver.ts (1)
448-451: Early throw aligns with other drivers – LGTMThe new synchronous
throwstandardises error handling across drivers and keeps semantics intact.src/driver/oracle/OracleDriver.ts (1)
346-348: Consistent error handling – looks goodMirrors the pattern adopted for the other drivers; behaviour remains unchanged for callers.
src/driver/postgres/PostgresDriver.ts (1)
588-590: Switch to synchronousthrowis correct and stylistically cleanerInside an
asyncfunction,throwstill results in a rejectedPromise, so behaviour for callers (await driver.disconnect(),.catch(), etc.) is unchanged.
The explicit exception also matches the pattern adopted across the other drivers in this PR, eliminating the extrareturnbranch. ✅src/driver/sqlserver/SqlServerDriver.ts (1)
333-335: Consistent error propagation across driversSame rationale as in
PostgresDriver: the synchronousthrowkeeps observable behaviour while aligning style with the rest of the code-base. Looks good.
(No further changes required.)src/driver/cockroachdb/CockroachDriver.ts (1)
349-351: Uniform exception style improves consistency – change looks goodSwitching from returning a rejected promise to throwing the
ConnectionIsNotSetErroraligns this driver with the other drivers and keeps async → rejected-promise semantics intact. No additional changes required.test/functional/query-builder/convert-to-entity/convert-to-entity.ts (1)
11-11: Suite title now accurately reflects scope – nice cleanupThe updated description makes it easier to locate the test when scanning logs.
test/functional/driver/mysql/connection-options/enable-query-timeout.ts (1)
11-11: Naming follows driver-centric convention – LGTMThe new title matches the hierarchy used by other driver option suites.
test/functional/driver/postgres/connection-options.ts (1)
10-10: Clearer, driver-scoped wording – good improvementRenaming the suite and test clarifies intent without altering behaviour.
Also applies to: 24-24
package.json (1)
111-111:Details
❓ Verification inconclusive
Verify chosen
@sap/hana-clientversionsThe dev/peer ranges look plausible, but the downgrade in devDependencies (
^2.23.27) warrants a quick sanity check that this version is published and free of critical CVEs.Also applies to: 167-167
🏁 Script executed:
#!/bin/bash # Check that the required versions exist and list known advisories (if any) set -e PACKAGE="@sap/hana-client" DEV_VERSION="2.23.27" PEER_RANGE="^2.14.22" echo "=== Available versions (abbrev) ===" curl -s https://registry.npmjs.org/${PACKAGE} | jq -r '.versions | keys | .[-10:]' echo "=== Verify specific dev version ===" npm view ${PACKAGE}@${DEV_VERSION} version echo "=== Audit advisories for dev version ===" npm audit --json | jq '.advisories[] | select(.module_name=="hana-client") | {severity, title, vulnerable_versions, patched_versions}'Length of output: 797
Confirm @sap/[email protected] is published and CVE-free
npm view @sap/[email protected] versionreturns2.23.27, so the version exists in the registry.- The sandbox
npm auditcheck returned no advisories forhana-client(emptyadvisories), but it ran without installing the package.- Please verify locally by running:
and confirm there are no critical vulnerabilities.npm install @sap/[email protected] npm audit- Ensure the peer dependency range (
^2.14.22) still aligns with your supported SAP HANA client versions.Locations:
• package.json → line 111
• package.json → line 167src/driver/sap/SapQueryRunner.ts (3)
1-1: Good use of Node.js protocol imports.Using the
node:prefix for built-in modules is a recommended practice that clearly distinguishes Node.js core modules from npm packages.
273-286: Excellent error handling for identity value retrieval.The refactoring properly handles errors by catching exceptions and throwing
QueryFailedErrorwith appropriate context. The async/await pattern improves readability.
308-308: Good async handling for statement cleanup.Using
promisifywithawaitensures proper cleanup of the statement resource in the finally block.src/driver/sap/SapConnectionOptions.ts (2)
22-29: Clear deprecation and documentation updates.The deprecation of
hanaClientDriverproperly guides users to thedriverproperty, and the updated comment reflects the new default driver.
35-93: Well-structured pool options migration.The new pool configuration options are clearly documented with defaults, and deprecated options provide helpful migration guidance. The transition from milliseconds to seconds for idle timeout is explicitly noted.
src/driver/sap/SapDriver.ts (7)
1-1: LGTM! Import additions are appropriate.The added imports support the refactored connection pooling and error handling implementation.
Also applies to: 4-4, 17-17, 20-20, 23-23, 29-30
249-268: Connection options properly updated for native driver.The connection options structure correctly aligns with the @sap/hana-client native API, and filtering undefined values prevents passing invalid options.
270-287: Pool options correctly configured with fallback values.The pool configuration properly handles backward compatibility with legacy options (
max,idleTimeout,poolSize) while supporting new pool options. The duplicate condition issue from the previous review has been correctly addressed.
290-290: Pool creation uses native driver API.The pool is correctly created using the native driver's
createPoolmethod.
331-337: Master connection obtaining properly implemented.The method correctly checks for pool existence and uses promisified getConnection for async operation.
344-346: Slave connection correctly delegates to master.This is the appropriate pattern when replication is not configured.
836-855: Dependency loading correctly simplified for native driver only.The method properly handles custom driver instances and falls back to loading @sap/hana-client, removing support for the deprecated hdb-pool package.
f7bd211 to
dec84e8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
docs/docs/data-source/2-data-source-options.md (1)
552-552: Standardize SSL key/cert/ca option formatting.Rather than grouping
key,certandcain one bullet, list each as its own option with a description and example.Example diff:
- - `key`, `cert` and `ca` for the encrypted connection. + - `key` — Private key for SSL (e.g., path to PEM file or Buffer). + - `cert` — Public certificate for SSL (e.g., path to PEM file or Buffer). + - `ca` — Certificate authority chain for SSL validation (e.g., path to PEM file or Buffer).🧰 Tools
🪛 LanguageTool
[uncategorized] ~552-~552: Loose punctuation mark.
Context: ...tificate. For example,true. -key,certandcafor the encrypted conne...(UNLIKELY_OPENING_PUNCTUATION)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
package-lock.jsonis excluded by!**/package-lock.jsonsample/playground/package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (20)
README-zh_CN.md(0 hunks)README.md(0 hunks)README_ko.md(0 hunks)docs/docs/data-source/2-data-source-options.md(1 hunks)docs/docs/getting-started.md(1 hunks)package.json(2 hunks)sample/playground/package.json(1 hunks)src/driver/cockroachdb/CockroachDriver.ts(1 hunks)src/driver/mongodb/MongoDriver.ts(1 hunks)src/driver/mysql/MysqlDriver.ts(1 hunks)src/driver/oracle/OracleDriver.ts(1 hunks)src/driver/postgres/PostgresDriver.ts(1 hunks)src/driver/sap/SapConnectionOptions.ts(2 hunks)src/driver/sap/SapDriver.ts(5 hunks)src/driver/sap/SapQueryRunner.ts(4 hunks)src/driver/sqlserver/SqlServerDriver.ts(1 hunks)src/platform/PlatformTools.ts(0 hunks)test/functional/driver/postgres/connection-options.ts(2 hunks)test/functional/driver/sap/connection-pool.ts(1 hunks)test/functional/query-builder/convert-to-entity/convert-to-entity.ts(1 hunks)
💤 Files with no reviewable changes (4)
- README_ko.md
- README.md
- src/platform/PlatformTools.ts
- README-zh_CN.md
✅ Files skipped from review due to trivial changes (1)
- package.json
🚧 Files skipped from review as they are similar to previous changes (14)
- test/functional/query-builder/convert-to-entity/convert-to-entity.ts
- test/functional/driver/postgres/connection-options.ts
- src/driver/postgres/PostgresDriver.ts
- sample/playground/package.json
- docs/docs/getting-started.md
- src/driver/oracle/OracleDriver.ts
- src/driver/mysql/MysqlDriver.ts
- src/driver/mongodb/MongoDriver.ts
- src/driver/cockroachdb/CockroachDriver.ts
- src/driver/sqlserver/SqlServerDriver.ts
- test/functional/driver/sap/connection-pool.ts
- src/driver/sap/SapConnectionOptions.ts
- src/driver/sap/SapQueryRunner.ts
- src/driver/sap/SapDriver.ts
🧰 Additional context used
🪛 LanguageTool
docs/docs/data-source/2-data-source-options.md
[uncategorized] ~552-~552: Loose punctuation mark.
Context: ...tificate. For example, true. - key, cert and ca for the encrypted conne...
(UNLIKELY_OPENING_PUNCTUATION)
dec84e8 to
332a036
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
♻️ Duplicate comments (1)
docs/docs/data-source/2-data-source-options.md (1)
543-554: List concrete pool sub-options for SAP
The bullet still says “Options for the connection pool” without enumerating the new properties (maxConnectedOrPooled,maxPooledIdleTime,pingCheck,poolCapacity,poolErrorHandler). Users migrating fromhdb-poolneed these details.🧰 Tools
🪛 LanguageTool
[uncategorized] ~552-~552: Loose punctuation mark.
Context: ...tificate. For example,true. -key,certandcafor the encrypted conne...(UNLIKELY_OPENING_PUNCTUATION)
🧹 Nitpick comments (3)
src/driver/sap/SapDriver.ts (2)
329-336:disconnect()swallowsclearerrors
pool.clearcan reject (network hiccup).
Becausemasteris nulled before awaiting, callers cannot retry or inspect state.- this.master = undefined - await promisify(pool.clear).call(pool) + try { + await promisify(pool.clear).call(pool) + } finally { + this.master = undefined + }
856-868: Custom driver path skipsstreamClientloadingWhen a consumer supplies a custom
driver,streamClientstaysundefined, yet later code may rely on it (e.g., BLOB streaming).
Either document that a custom driver must also expose.Streamor attempt to load the extension here.- if (client) { - this.client = client - return - } + if (client) { + this.client = client + // try to load stream extension for custom build as well + try { + this.streamClient = + this.options.streamDriver ?? + PlatformTools.load("@sap/hana-client/extension/Stream") + } catch {/* optional */} + return + }docs/docs/data-source/2-data-source-options.md (1)
550-553: Minor punctuation / wording tweakA single bullet combines three option names without back-ticks and lacks a verb.
- - `key`, `cert` and `ca` for the encrypted connection. + - `key`, `cert`, `ca` — client-side key-pair / CA bundle used when `encrypt` is enabled.🧰 Tools
🪛 LanguageTool
[uncategorized] ~552-~552: Loose punctuation mark.
Context: ...tificate. For example,true. -key,certandcafor the encrypted conne...(UNLIKELY_OPENING_PUNCTUATION)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
package-lock.jsonis excluded by!**/package-lock.jsonsample/playground/package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (20)
README-zh_CN.md(0 hunks)README.md(0 hunks)README_ko.md(0 hunks)docs/docs/data-source/2-data-source-options.md(1 hunks)docs/docs/getting-started.md(1 hunks)package.json(2 hunks)sample/playground/package.json(1 hunks)src/driver/cockroachdb/CockroachDriver.ts(1 hunks)src/driver/mongodb/MongoDriver.ts(1 hunks)src/driver/mysql/MysqlDriver.ts(1 hunks)src/driver/oracle/OracleDriver.ts(1 hunks)src/driver/postgres/PostgresDriver.ts(1 hunks)src/driver/sap/SapConnectionOptions.ts(2 hunks)src/driver/sap/SapDriver.ts(6 hunks)src/driver/sap/SapQueryRunner.ts(5 hunks)src/driver/sqlserver/SqlServerDriver.ts(1 hunks)src/platform/PlatformTools.ts(0 hunks)test/functional/driver/postgres/connection-options.ts(2 hunks)test/functional/driver/sap/connection-pool.ts(1 hunks)test/functional/query-builder/convert-to-entity/convert-to-entity.ts(1 hunks)
💤 Files with no reviewable changes (4)
- README_ko.md
- README.md
- src/platform/PlatformTools.ts
- README-zh_CN.md
🚧 Files skipped from review as they are similar to previous changes (14)
- test/functional/query-builder/convert-to-entity/convert-to-entity.ts
- src/driver/mysql/MysqlDriver.ts
- test/functional/driver/postgres/connection-options.ts
- package.json
- src/driver/postgres/PostgresDriver.ts
- docs/docs/getting-started.md
- src/driver/sqlserver/SqlServerDriver.ts
- sample/playground/package.json
- src/driver/oracle/OracleDriver.ts
- src/driver/cockroachdb/CockroachDriver.ts
- src/driver/mongodb/MongoDriver.ts
- src/driver/sap/SapQueryRunner.ts
- test/functional/driver/sap/connection-pool.ts
- src/driver/sap/SapConnectionOptions.ts
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/driver/sap/SapDriver.ts (3)
src/platform/PlatformTools.ts (2)
error(267-269)PlatformTools(17-279)src/error/ConnectionIsNotSetError.ts (1)
ConnectionIsNotSetError(6-12)src/error/TypeORMError.ts (1)
TypeORMError(1-17)
🪛 LanguageTool
docs/docs/data-source/2-data-source-options.md
[uncategorized] ~552-~552: Loose punctuation mark.
Context: ...tificate. For example, true. - key, cert and ca for the encrypted conne...
(UNLIKELY_OPENING_PUNCTUATION)
⏰ Context from checks skipped due to timeout of 90000ms (19)
- GitHub Check: database-tests (18) / mysql_mariadb
- GitHub Check: database-tests (18) / mssql (^11.0.1)
- GitHub Check: database-tests (18) / mssql (^9.1.1)
- GitHub Check: database-tests (18) / cockroachdb
- GitHub Check: database-tests (16) / better-sqlite3
- GitHub Check: database-tests (16) / mssql (^9.1.1)
- GitHub Check: database-tests (16) / mongodb
- GitHub Check: database-tests (16) / sqljs
- GitHub Check: database-tests (16) / mssql (^11.0.1)
- GitHub Check: database-tests (16) / cockroachdb
- GitHub Check: database-tests (16) / sqlite
- GitHub Check: database-tests-compose (20) / sap
- GitHub Check: database-tests-compose (20) / oracle
- GitHub Check: database-tests-compose (18) / sap
- GitHub Check: database-tests-windows / sqljs
- GitHub Check: database-tests-compose (18) / oracle
- GitHub Check: database-tests-windows / better-sqlite3
- GitHub Check: database-tests-windows / sqlite
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (2)
src/driver/sap/SapDriver.ts (2)
344-357:obtainMasterConnectionleaks on handler failureIf
pool.getConnectionsucceeds butthis.poolErrorHandlerlater throws (unlikely but possible), the obtained connection is already released to the caller and no longer tracked – we end up with an uncaught error and a live connection.Wrap the error handler in
try { await … } catch { /* swallow */ }or treat it as sync callback.
276-287: 🛠️ Refactor suggestion
maxPooledIdleTimeexpects seconds, we pass milliseconds for old optionYou convert the deprecated
idleTimeout(which is in milliseconds) to seconds by dividing by 1000 – ✅.
However the new option also wants seconds, so if a user already moved tomaxPooledIdleTimeand still thinks in milliseconds their value will be interpreted 1000× too high.Consider normalising both options to seconds to avoid a silent behaviour change.
- maxPooledIdleTime: - this.options.pool?.maxPooledIdleTime ?? + maxPooledIdleTime: + this.options.pool?.maxPooledIdleTime !== undefined + ? this.options.pool.maxPooledIdleTime // assume seconds + : this.options.pool?.idleTimeout + ? this.options.pool.idleTimeout / 1000 // ms → s + : 30,Likely an incorrect or invalid review comment.
332a036 to
d4fd357
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
♻️ Duplicate comments (3)
src/driver/sap/SapDriver.ts (2)
255-267: Still using undocumented alias keys for @sap/hana-clientThis block relies on
host,user,password,database, etc., which are undocumented aliases in@sap/hana-client. Switching to the official keys (serverNode,uid,pwd,databaseName, …) avoids future breakage.
302-305:⚠️ Potential issuePool errors are never surfaced – attach the handler
this.poolErrorHandleris defined but the pool created on line 303 never subscribes to it. Unhandled pool errors will be lost.this.master = this.client.createPool(connectionOptions, poolOptions) +// Forward asynchronous pool errors to the configured handler +if (this.master?.on) { + this.master.on("error", this.poolErrorHandler) +}docs/docs/data-source/2-data-source-options.md (1)
553-554: Document the new pool sub-optionsThe bullet merely says “
pool– Options for the connection pool.” Please enumeratemaxConnectedOrPooled,maxPooledIdleTime,pingCheck,poolCapacity, etc., so users know what is supported.
🧹 Nitpick comments (4)
test/functional/driver/mysql/connection-options/enable-query-timeout.ts (1)
19-21: Unit-suffix variables improve readability
timeoutMsconveys its unit, whilelongQueryTimeSec/shortQueryTimeSecdo too – consider renamingtimeoutMstotimeoutMs➜queryTimeoutMsor dropping the suffix for consistency.src/driver/sap/SapDriver.ts (2)
329-336: Safe-guardpool.clearinvocation
promisify(pool.clear)will throw ifpool.clearis already promisified or not a function. Guarding once more keeps shutdown resilient:- await promisify(pool.clear).call(pool) + if (typeof pool.clear === "function") { + await promisify(pool.clear).call(pool) + }
344-357:obtainMasterConnectionleaks connection on error pathWhen
getConnectionsucceeds, caller is responsible forrelease().
On error, the pool error handler runs but the error is re-thrown ‑ that’s fine.
However, add a try/catch around the promisified call in case the handler itself rejects and masks the original error.docs/docs/data-source/2-data-source-options.md (1)
545-553: Minor markdown/style polish– Bullet
key, cert and calacks back-ticks individually;
– Consider aligning true/false examples (true➜true) for consistency.🧰 Tools
🪛 LanguageTool
[uncategorized] ~552-~552: Loose punctuation mark.
Context: ...tificate. For example,true. -key,certandcafor the encrypted conne...(UNLIKELY_OPENING_PUNCTUATION)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
package-lock.jsonis excluded by!**/package-lock.jsonsample/playground/package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (21)
README-zh_CN.md(0 hunks)README.md(0 hunks)README_ko.md(0 hunks)docs/docs/data-source/2-data-source-options.md(1 hunks)docs/docs/getting-started.md(1 hunks)package.json(2 hunks)sample/playground/package.json(1 hunks)src/driver/cockroachdb/CockroachDriver.ts(1 hunks)src/driver/mongodb/MongoDriver.ts(1 hunks)src/driver/mysql/MysqlDriver.ts(1 hunks)src/driver/oracle/OracleDriver.ts(1 hunks)src/driver/postgres/PostgresDriver.ts(1 hunks)src/driver/sap/SapConnectionOptions.ts(2 hunks)src/driver/sap/SapDriver.ts(6 hunks)src/driver/sap/SapQueryRunner.ts(5 hunks)src/driver/sqlserver/SqlServerDriver.ts(1 hunks)src/platform/PlatformTools.ts(0 hunks)test/functional/driver/mysql/connection-options/enable-query-timeout.ts(4 hunks)test/functional/driver/postgres/connection-options.ts(2 hunks)test/functional/driver/sap/connection-pool.ts(1 hunks)test/functional/query-builder/convert-to-entity/convert-to-entity.ts(1 hunks)
💤 Files with no reviewable changes (4)
- README.md
- README_ko.md
- src/platform/PlatformTools.ts
- README-zh_CN.md
🚧 Files skipped from review as they are similar to previous changes (14)
- test/functional/query-builder/convert-to-entity/convert-to-entity.ts
- test/functional/driver/postgres/connection-options.ts
- src/driver/mysql/MysqlDriver.ts
- src/driver/oracle/OracleDriver.ts
- sample/playground/package.json
- src/driver/mongodb/MongoDriver.ts
- src/driver/postgres/PostgresDriver.ts
- docs/docs/getting-started.md
- package.json
- src/driver/cockroachdb/CockroachDriver.ts
- src/driver/sap/SapQueryRunner.ts
- src/driver/sqlserver/SqlServerDriver.ts
- test/functional/driver/sap/connection-pool.ts
- src/driver/sap/SapConnectionOptions.ts
🧰 Additional context used
🧬 Code Graph Analysis (2)
test/functional/driver/mysql/connection-options/enable-query-timeout.ts (1)
test/utils/test-utils.ts (1)
TestingOptions(38-168)
src/driver/sap/SapDriver.ts (3)
src/platform/PlatformTools.ts (2)
error(267-269)PlatformTools(17-279)src/error/ConnectionIsNotSetError.ts (1)
ConnectionIsNotSetError(6-12)src/error/TypeORMError.ts (1)
TypeORMError(1-17)
🪛 LanguageTool
docs/docs/data-source/2-data-source-options.md
[uncategorized] ~552-~552: Loose punctuation mark.
Context: ...tificate. For example, true. - key, cert and ca for the encrypted conne...
(UNLIKELY_OPENING_PUNCTUATION)
⏰ Context from checks skipped due to timeout of 90000ms (17)
- GitHub Check: database-tests (18) / mysql_mariadb
- GitHub Check: database-tests (16) / postgres (14-3.5)
- GitHub Check: database-tests (16) / postgres (17-3.5)
- GitHub Check: database-tests (16) / mysql_mariadb
- GitHub Check: database-tests (16) / mongodb
- GitHub Check: database-tests (16) / better-sqlite3
- GitHub Check: database-tests (16) / mssql (^9.1.1)
- GitHub Check: database-tests (16) / mssql (^10.0.1)
- GitHub Check: database-tests-compose (20) / sap
- GitHub Check: database-tests (16) / cockroachdb
- GitHub Check: database-tests-compose (20) / oracle
- GitHub Check: database-tests-compose (18) / oracle
- GitHub Check: database-tests-compose (18) / sap
- GitHub Check: database-tests-windows / sqljs
- GitHub Check: database-tests-windows / better-sqlite3
- GitHub Check: database-tests-windows / sqlite
- GitHub Check: Analyze (javascript-typescript)
test/functional/driver/mysql/connection-options/enable-query-timeout.ts
Outdated
Show resolved
Hide resolved
d4fd357 to
b2e3271
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (3)
docs/docs/data-source/2-data-source-options.md (1)
557-558: Document the concrete pool sub-options instead of a generic placeholder.The previous review already requested enumerating the new SAP-specific pool keys, but the doc still reads
- \pool` - Options for the connection pool.without listing anything. Please expand this bullet with the actual keys (maxConnectedOrPooled,maxPooledIdleTime,pingCheck,poolCapacity,poolErrorHandler`, …) and their defaults so users know what to configure.src/driver/sap/SapDriver.ts (2)
255-267: Still using non-standard option names – align with @sap/hana-client spec.
@sap/hana-clientofficially expects
serverNode,uid,pwd,databaseName, …
Usinghost,user,password,databaserelies on undocumented alias mapping that can break on upgrade.Re-map the keys before calling
createPool(see prior diff suggestion).
294-305: Pool errors never surface – attach the error handler to the pool.
poolErrorHandleris defined but the newly created pool isn’t subscribed to it, so async errors are swallowed.this.master = this.client.createPool(connectionOptions, poolOptions) +// surface async pool errors +if (this.master?.on) { + this.master.on("error", this.poolErrorHandler) +}
🧹 Nitpick comments (1)
docs/docs/data-source/2-data-source-options.md (1)
555-556: Minor wording / punctuation nit“
key,certandcafor the encrypted connection.” → “key,cert, andcafor the encrypted connection.” (add the serial comma).
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (14)
README-zh_CN.md(0 hunks)README.md(0 hunks)README_ko.md(0 hunks)docs/docs/data-source/2-data-source-options.md(1 hunks)docs/docs/getting-started.md(1 hunks)package.json(1 hunks)src/driver/sap/SapConnectionOptions.ts(2 hunks)src/driver/sap/SapDriver.ts(6 hunks)src/driver/sap/SapQueryRunner.ts(5 hunks)src/platform/PlatformTools.ts(0 hunks)test/functional/driver/mysql/connection-options/enable-query-timeout.ts(4 hunks)test/functional/driver/postgres/connection-options.ts(2 hunks)test/functional/driver/sap/connection-pool.ts(1 hunks)test/functional/query-builder/convert-to-entity/convert-to-entity.ts(1 hunks)
💤 Files with no reviewable changes (4)
- src/platform/PlatformTools.ts
- README_ko.md
- README.md
- README-zh_CN.md
✅ Files skipped from review due to trivial changes (1)
- docs/docs/getting-started.md
🚧 Files skipped from review as they are similar to previous changes (7)
- test/functional/query-builder/convert-to-entity/convert-to-entity.ts
- test/functional/driver/postgres/connection-options.ts
- package.json
- test/functional/driver/mysql/connection-options/enable-query-timeout.ts
- test/functional/driver/sap/connection-pool.ts
- src/driver/sap/SapQueryRunner.ts
- src/driver/sap/SapConnectionOptions.ts
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/driver/sap/SapDriver.ts (3)
src/platform/PlatformTools.ts (2)
error(267-269)PlatformTools(17-279)src/error/ConnectionIsNotSetError.ts (1)
ConnectionIsNotSetError(6-12)src/error/TypeORMError.ts (1)
TypeORMError(1-17)
🪛 LanguageTool
docs/docs/data-source/2-data-source-options.md
[uncategorized] ~556-~556: Loose punctuation mark.
Context: ...tificate. For example, true. - key, cert and ca for the encrypted conne...
(UNLIKELY_OPENING_PUNCTUATION)
⏰ Context from checks skipped due to timeout of 90000ms (19)
- GitHub Check: tests-linux (20) / mongodb
- GitHub Check: tests-linux (20) / oracle
- GitHub Check: tests-linux (20) / sap
- GitHub Check: tests-linux (20) / sqljs
- GitHub Check: tests-linux (20) / mysql_mariadb
- GitHub Check: tests-linux (20) / cockroachdb
- GitHub Check: tests-linux (18) / better-sqlite3
- GitHub Check: tests-linux (18) / mysql_mariadb
- GitHub Check: tests-linux (18) / oracle
- GitHub Check: tests-linux (18) / sap
- GitHub Check: tests-linux (18) / postgres (14-3.5)
- GitHub Check: tests-linux (18) / postgres (17-3.5)
- GitHub Check: tests-linux (18) / sqlite
- GitHub Check: tests-linux (18) / mongodb
- GitHub Check: tests-linux (18) / mssql
- GitHub Check: tests-windows / sqljs
- GitHub Check: tests-windows / better-sqlite3
- GitHub Check: tests-windows / sqlite
- GitHub Check: Analyze (javascript-typescript)
b2e3271 to
9b2274f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
♻️ Duplicate comments (2)
src/driver/sap/SapDriver.ts (2)
250-262: Prefer official@sap/hana-clientproperty names (serverNode,uid,pwd,databaseName)The driver still builds
connectionOptionswith undocumented alias keys (host,user,password,database).
Relying on the alias mapping that happens to work today is brittle and may break on future client releases.-const connectionOptions: any = { - host: this.options.host, - port: this.options.port, - user: this.options.username, - password: this.options.password, - database: this.options.database, - currentSchema: this.options.schema, +const connectionOptions: any = { + // required by @sap/hana-client + serverNode: `${this.options.host}:${this.options.port}`, + uid: this.options.username, + pwd: this.options.password, + databaseName: this.options.database, + currentSchema: this.options.schema, }This was raised in a previous review but is still unresolved.
Please adopt the canonical keys or add an inline comment that the alias mapping is guaranteed by SAP.
291-296: Poolerrorevents are still not surfacedThe pool-level error handler suggested earlier was never attached, so asynchronous errors remain silent.
this.master = this.client.createPool(connectionOptions, poolOptions) +// surface pool errors +this.master.on?.("error", this.options.poolErrorHandler ?? ((err: any) => + this.connection.logger?.warn(`[HANA pool] ${err.message}`, err)))Please attach the handler (or explicitly document why it is unnecessary).
🧹 Nitpick comments (2)
src/driver/sap/SapDriver.ts (1)
837-855: DeprecatedhanaClientDriveroption keeps sneaking back in
SapConnectionOptionswas refactored to drophanaClientDriver, yetloadDependencies()still checks for it.
If the type definition no longer exposes that field this will compile but be dead code; if it does exist you now have two mutually-exclusive ways to inject a driver.Either:
- Remove the fallback to
options.hanaClientDriver, or- Mark it
/** @deprecated */in the options interface and add an inline JSDoc explaining the migration path.docs/docs/data-source/2-data-source-options.md (1)
556-562: Fix list indentation & punctuation in the newsapsectionMarkdown-lint flags the sub-list for pool options (+ minor loose comma).
Align all bullets two spaces under their parent and add a serial comma afterca.- - `key`, `cert` and `ca` - Private key, public certificate and certificate authority for the encrypted connection. - - `pool` — Connection pool configuration object: - - `maxConnectedOrPooled` (number) — Max active or idle connections in the pool (default: 10). - - `maxPooledIdleTime` (seconds) — Time before an idle connection is closed (default: 30). - - `pingCheck` (boolean) — Whether to validate connections before use (default: false). - - `poolCapacity` (number) — Maximum number of connections to be kept available (default: no limit). +- `key`, `cert`, and `ca` – private key, public certificate, and certificate authority for the encrypted connection. +- `pool` — connection-pool configuration object: + - `maxConnectedOrPooled` (number) — maximum active or idle connections (default 10) + - `maxPooledIdleTime` (seconds) — idle timeout before a connection is closed (default 30) + - `pingCheck` (boolean) — ping connection before use (default false) + - `poolCapacity` (number) — hard upper limit for connections (unbounded by default)This resolves
MD007and the LanguageTool warning.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (14)
README-zh_CN.md(0 hunks)README.md(0 hunks)README_ko.md(0 hunks)docs/docs/data-source/2-data-source-options.md(1 hunks)docs/docs/getting-started.md(1 hunks)package.json(1 hunks)src/driver/sap/SapConnectionOptions.ts(1 hunks)src/driver/sap/SapDriver.ts(6 hunks)src/driver/sap/SapQueryRunner.ts(5 hunks)src/platform/PlatformTools.ts(0 hunks)test/functional/driver/mysql/connection-options/enable-query-timeout.ts(4 hunks)test/functional/driver/postgres/connection-options.ts(2 hunks)test/functional/driver/sap/connection-pool.ts(1 hunks)test/functional/query-builder/convert-to-entity/convert-to-entity.ts(1 hunks)
💤 Files with no reviewable changes (4)
- README_ko.md
- README.md
- src/platform/PlatformTools.ts
- README-zh_CN.md
🚧 Files skipped from review as they are similar to previous changes (8)
- test/functional/query-builder/convert-to-entity/convert-to-entity.ts
- test/functional/driver/postgres/connection-options.ts
- package.json
- test/functional/driver/sap/connection-pool.ts
- test/functional/driver/mysql/connection-options/enable-query-timeout.ts
- docs/docs/getting-started.md
- src/driver/sap/SapQueryRunner.ts
- src/driver/sap/SapConnectionOptions.ts
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/driver/sap/SapDriver.ts (3)
src/error/ConnectionIsNotSetError.ts (1)
ConnectionIsNotSetError(6-12)src/error/TypeORMError.ts (1)
TypeORMError(1-17)src/platform/PlatformTools.ts (1)
PlatformTools(17-279)
🪛 LanguageTool
docs/docs/data-source/2-data-source-options.md
[uncategorized] ~556-~556: Loose punctuation mark.
Context: ...tificate. For example, true. - key, cert and ca - Private key, public c...
(UNLIKELY_OPENING_PUNCTUATION)
🪛 markdownlint-cli2 (0.17.2)
docs/docs/data-source/2-data-source-options.md
558-558: Unordered list indentation
Expected: 2; Actual: 4
(MD007, ul-indent)
559-559: Unordered list indentation
Expected: 2; Actual: 4
(MD007, ul-indent)
560-560: Unordered list indentation
Expected: 2; Actual: 4
(MD007, ul-indent)
561-561: Unordered list indentation
Expected: 2; Actual: 4
(MD007, ul-indent)
⏰ Context from checks skipped due to timeout of 90000ms (20)
- GitHub Check: tests-linux (20) / cockroachdb
- GitHub Check: tests-linux (20) / mongodb
- GitHub Check: tests-linux (20) / mssql
- GitHub Check: tests-linux (20) / sap
- GitHub Check: tests-linux (18) / postgres (14-3.5)
- GitHub Check: tests-linux (18) / oracle
- GitHub Check: tests-linux (20) / mysql_mariadb
- GitHub Check: tests-linux (20) / sqljs
- GitHub Check: tests-linux (18) / sqljs
- GitHub Check: tests-linux (18) / sap
- GitHub Check: tests-linux (18) / postgres (17-3.5)
- GitHub Check: tests-linux (18) / mssql
- GitHub Check: tests-linux (18) / better-sqlite3
- GitHub Check: tests-linux (18) / mongodb
- GitHub Check: tests-linux (18) / sqlite
- GitHub Check: tests-linux (18) / mysql_mariadb
- GitHub Check: tests-windows / sqljs
- GitHub Check: tests-windows / sqlite
- GitHub Check: tests-windows / better-sqlite3
- GitHub Check: Analyze (javascript-typescript)
9b2274f to
6ecee87
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (3)
src/driver/sap/SapDriver.ts (3)
250-262: Consider using official SAP HANA Client property names.The connection options still use non-standard keys like
host,user,password, anddatabasewhich rely on undocumented alias mapping in@sap/hana-client. Using the official property names would be more robust.Consider this refactor to align with the official HANA client specification:
- const connectionOptions: any = { - host: this.options.host, - port: this.options.port, - user: this.options.username, - password: this.options.password, - database: this.options.database, + const connectionOptions: any = { + serverNode: `${this.options.host}:${this.options.port}`, + uid: this.options.username, + pwd: this.options.password, + databaseName: this.options.database,
277-281: Clarify time unit handling for maxPooledIdleTime.The unit conversion logic mixes milliseconds and seconds, which could cause confusion when
maxPooledIdleTimeis provided directly versus converted fromidleTimeout.Consider normalizing to seconds consistently:
- maxPooledIdleTime: - this.options.pool?.maxPooledIdleTime ?? - (this.options.pool?.idleTimeout - ? this.options.pool.idleTimeout / 1000 - : 30), + // hana-client expects seconds + maxPooledIdleTime: + this.options.pool?.maxPooledIdleTime ?? + (this.options.pool?.idleTimeout + ? Math.ceil(this.options.pool.idleTimeout / 1000) + : 30),
291-291: Pool error handler is not attached to the pool.The pool is created but no error event listener is attached, which means pool-level errors won't be handled properly.
Add error handling after pool creation:
this.master = this.client.createPool(connectionOptions, poolOptions) +// Attach error handler for pool-level errors +if (this.master.on) { + this.master.on("error", (error: any) => { + // Log pool errors or handle them appropriately + console.error("Pool error:", error) + }) +}
🧹 Nitpick comments (1)
docs/docs/data-source/2-data-source-options.md (1)
558-561: Fix markdown list indentation.The nested list items use 4-space indentation instead of the expected 2-space indentation, causing markdown linting errors.
Apply this formatting fix:
- - `maxConnectedOrPooled` (number) — Max active or idle connections in the pool (default: 10). - - `maxPooledIdleTime` (seconds) — Time before an idle connection is closed (default: 30). - - `pingCheck` (boolean) — Whether to validate connections before use (default: false). - - `poolCapacity` (number) — Maximum number of connections to be kept available (default: no limit). + - `maxConnectedOrPooled` (number) — Max active or idle connections in the pool (default: 10). + - `maxPooledIdleTime` (seconds) — Time before an idle connection is closed (default: 30). + - `pingCheck` (boolean) — Whether to validate connections before use (default: false). + - `poolCapacity` (number) — Maximum number of connections to be kept available (default: no limit).
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (11)
README-zh_CN.md(0 hunks)README.md(0 hunks)README_ko.md(0 hunks)docs/docs/data-source/2-data-source-options.md(1 hunks)docs/docs/getting-started.md(1 hunks)package.json(1 hunks)src/driver/sap/SapConnectionOptions.ts(1 hunks)src/driver/sap/SapDriver.ts(6 hunks)src/driver/sap/SapQueryRunner.ts(5 hunks)src/platform/PlatformTools.ts(0 hunks)test/functional/driver/sap/connection-pool.ts(1 hunks)
💤 Files with no reviewable changes (4)
- README_ko.md
- README.md
- src/platform/PlatformTools.ts
- README-zh_CN.md
🚧 Files skipped from review as they are similar to previous changes (5)
- package.json
- docs/docs/getting-started.md
- test/functional/driver/sap/connection-pool.ts
- src/driver/sap/SapQueryRunner.ts
- src/driver/sap/SapConnectionOptions.ts
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/driver/sap/SapDriver.ts (2)
src/error/TypeORMError.ts (1)
TypeORMError(1-17)src/platform/PlatformTools.ts (1)
PlatformTools(17-279)
🪛 LanguageTool
docs/docs/data-source/2-data-source-options.md
[uncategorized] ~556-~556: Loose punctuation mark.
Context: ...tificate. For example, true. - key, cert and ca - Private key, public c...
(UNLIKELY_OPENING_PUNCTUATION)
🪛 markdownlint-cli2 (0.17.2)
docs/docs/data-source/2-data-source-options.md
558-558: Unordered list indentation
Expected: 2; Actual: 4
(MD007, ul-indent)
559-559: Unordered list indentation
Expected: 2; Actual: 4
(MD007, ul-indent)
560-560: Unordered list indentation
Expected: 2; Actual: 4
(MD007, ul-indent)
561-561: Unordered list indentation
Expected: 2; Actual: 4
(MD007, ul-indent)
🔇 Additional comments (2)
src/driver/sap/SapDriver.ts (2)
326-347: LGTM! Well-implemented async connection methods.The new async connection methods properly use
promisifyand provide appropriate error handling. The slave connection method correctly delegates to the master connection method for non-replicated setups.
837-856: LGTM! Improved dependency loading logic.The refactored
loadDependenciesmethod properly prioritizes explicit driver options and provides clear fallback behavior with appropriate error handling.
6ecee87 to
6c6cbcb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
docs/docs/data-source/2-data-source-options.md (1)
558-561: Fix MD007 indentation for the nestedpooloptions listMarkdown-lint is currently flagging these four lines because the sub-list is indented by 4 spaces instead of 2.
Adjusting the indentation keeps the document consistent with the rest of the file and removes the linter warning.- - `maxConnectedOrPooled` (number) — Max active or idle connections in the pool (default: 10). - - `maxPooledIdleTime` (seconds) — Time before an idle connection is closed (default: 30). - - `pingCheck` (boolean) — Whether to validate connections before use (default: false). - - `poolCapacity` (number) — Maximum number of connections to be kept available (default: no limit). + - `maxConnectedOrPooled` (number) — Max active or idle connections in the pool (default: 10). + - `maxPooledIdleTime` (seconds) — Time before an idle connection is closed (default: 30). + - `pingCheck` (boolean) — Whether to validate connections before use (default: false). + - `poolCapacity` (number) — Maximum number of connections to be kept available (default: no limit).
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (11)
README-zh_CN.md(0 hunks)README.md(0 hunks)README_ko.md(0 hunks)docs/docs/data-source/2-data-source-options.md(1 hunks)docs/docs/getting-started.md(1 hunks)package.json(1 hunks)src/driver/sap/SapConnectionOptions.ts(1 hunks)src/driver/sap/SapDriver.ts(7 hunks)src/driver/sap/SapQueryRunner.ts(7 hunks)src/platform/PlatformTools.ts(0 hunks)test/functional/driver/sap/connection-pool.ts(1 hunks)
💤 Files with no reviewable changes (4)
- README_ko.md
- src/platform/PlatformTools.ts
- README-zh_CN.md
- README.md
🚧 Files skipped from review as they are similar to previous changes (6)
- package.json
- docs/docs/getting-started.md
- test/functional/driver/sap/connection-pool.ts
- src/driver/sap/SapConnectionOptions.ts
- src/driver/sap/SapDriver.ts
- src/driver/sap/SapQueryRunner.ts
🧰 Additional context used
🪛 LanguageTool
docs/docs/data-source/2-data-source-options.md
[uncategorized] ~556-~556: Loose punctuation mark.
Context: ...tificate. For example, true. - key, cert and ca - Private key, public c...
(UNLIKELY_OPENING_PUNCTUATION)
🪛 markdownlint-cli2 (0.17.2)
docs/docs/data-source/2-data-source-options.md
558-558: Unordered list indentation
Expected: 2; Actual: 4
(MD007, ul-indent)
559-559: Unordered list indentation
Expected: 2; Actual: 4
(MD007, ul-indent)
560-560: Unordered list indentation
Expected: 2; Actual: 4
(MD007, ul-indent)
561-561: Unordered list indentation
Expected: 2; Actual: 4
(MD007, ul-indent)
⏰ Context from checks skipped due to timeout of 90000ms (20)
- GitHub Check: tests-linux (20) / sap
- GitHub Check: tests-linux (20) / postgres (17-3.5)
- GitHub Check: tests-linux (20) / postgres (14-3.5)
- GitHub Check: tests-linux (20) / mysql_mariadb
- GitHub Check: tests-linux (20) / mongodb
- GitHub Check: tests-linux (20) / cockroachdb
- GitHub Check: tests-linux (18) / sqlite
- GitHub Check: tests-linux (18) / mssql
- GitHub Check: tests-linux (18) / mongodb
- GitHub Check: tests-linux (18) / sap
- GitHub Check: tests-linux (18) / oracle
- GitHub Check: tests-linux (18) / postgres (14-3.5)
- GitHub Check: tests-linux (18) / postgres (17-3.5)
- GitHub Check: tests-linux (18) / sqljs
- GitHub Check: tests-linux (18) / mysql_mariadb
- GitHub Check: tests-linux (18) / better-sqlite3
- GitHub Check: tests-windows / better-sqlite3
- GitHub Check: tests-windows / sqljs
- GitHub Check: tests-windows / sqlite
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (1)
docs/docs/data-source/2-data-source-options.md (1)
559-560: Double-check the time unit formaxPooledIdleTimeThe docs state the value is in seconds, but SAP HANA Client’s PoolOptions API expects the time in milliseconds (
maxPooledIdleTimevs.idleTimeout).
Please verify the unit used inSapDriverand update the wording or example accordingly — otherwise users may unknowingly set an idle timeout 1000× longer than intended.
d34179d to
15fb3e9
Compare
gioboa
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏 @alumni
sgarner
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, nice one @alumni 👌
I saw some config deprecations but I assume the pooling functionality is equivalent. So this is safe to include in a minor release, right?
| // HANA connection info | ||
| const dbParams = { | ||
| hostName: this.options.host, | ||
| const connectionOptions: any = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the client library not provide typings that we could use for these options objects? 😞
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does, but in TypeORM we can't really use types from the database clients, because we would need to have these clients as direct dependencies.
I'm hoping we would do two things in the future:
- short term: import types using type imports. We can easily configure eslint to convert imports to type imports when possible, which would allow us to import types from devDependencies in the TypeORM source code (although only internally).
- long term: extract drivers into separate packages which import the clients / use them as peer dependencies. For the existing drivers it would allow better typing, also externally, for TypeORM users.
BTW, while I did this change I imported the types from HANA Client to make things easier for myself and removed them after, so that users that don't rely on the SAP Driver don't have to import the client library.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, but type elision will remove from the compiled output any imports that are only used as types. So importing types from devDependencies shouldn't cause any issues for users; and anyone using the SapDriver will need the peerDependency installed anyway. What am I missing?
Using import type to make this explicit would be even better, of course.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we use TSC (not e.g. Webpack), there's no tree-shaking, so imports will not be removed. If we have type imports we might be able to get away in some situations (maybe in SapDriver, but not in SapConnectionOptions).
Later edit: verbatimModuleSyntax is not enabled in our TSConfig (I though it's the default behavior). I would still keep things as they are and add types later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we use TSC (not e.g. Webpack), there's no tree-shaking, so imports will not be removed. If we have type imports we might be able to get away in some situations (maybe in
SapDriver, but not inSapConnectionOptions).
Tree shaking isn't necessary, this is a TSC feature:
But yes, a distinction has to be made that we can't reference such imports in exported types like SapConnectionOptions, which do appear in our output .d.ts files. Dev dependencies can only be imported for use in internal typings.
I tried to keep things as compatible as possible with the previous pooling library. There are some settings that will have no effect anymore, since they don't have an equivalent, but it won't be a breaking change, e.g.: the timeout setting is not used, so now trying to acquire a connection from the pool when the pool is full will fail, but the chance of failure now is much lower than the chance of timeout with the old pool (with the same pool size) - the old pool was buggy. Seems the preference within SAP is to release this ASAP as the security compliance teams are pressuring every development team to drop no longer maintained libraries like the old pool. |
gioboa
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏
* feat(sap): use the native driver for connection pooling * Add pool error handler
Description of change
Implements connection pooling for the SAP HANA driver using the built-in explicit pooling functions of
@sap/hana-client.This helps remove the deprecated
hdb-poollibrary, which hasn't been updated in 5 years. Fixes #9890.Pull-Request Checklist
masterbranchFixes #00000Summary by CodeRabbit
New Features
Bug Fixes
Refactor
Documentation
Tests
Chores