Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@alumni
Copy link
Collaborator

@alumni alumni commented Jun 10, 2025

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-pool library, which hasn't been updated in 5 years. Fixes #9890.

Pull-Request Checklist

  • Code is up-to-date with the master branch
  • This pull request links relevant issues as Fixes #00000
  • There are new or updated unit tests validating the change
  • Documentation has been updated to reflect this change

Summary by CodeRabbit

  • New Features

    • Added support for new SAP HANA connection pool configuration options, including maximum pool size, idle time, ping checks, and pool capacity.
    • Introduced new documentation for SAP HANA data source options and connection pooling.
  • Bug Fixes

    • Improved error handling and connection management for SAP HANA driver connections.
  • Refactor

    • Modernized SAP HANA driver to use async/await and streamlined connection and pool option handling.
    • Deprecated and removed legacy pool options in favor of new configuration.
    • Enhanced query execution and streaming with better async handling and error management.
    • Simplified dependency loading and prioritized provided drivers over dynamic loading.
  • Documentation

    • Updated installation instructions for SAP HANA, removing references to deprecated packages and sponsorship notes.
    • Clarified and expanded SAP HANA configuration documentation.
  • Tests

    • Added new functional tests to verify SAP HANA connection pool behavior.
  • Chores

    • Removed deprecated SAP HANA dependencies from the package configuration.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 10, 2025

Walkthrough

This change removes the dependency on the hdb-pool package and refactors the SAP HANA driver to use only @sap/hana-client for database connections and pooling. Documentation and configuration options are updated to reflect the new pooling parameters. Connection and query management are modernized with async/await and improved error handling. A new test validates the updated connection pool behavior.

Changes

Files / Groups Change Summary
README.md, README_ko.md, README-zh_CN.md, docs/docs/getting-started.md Removed hdb-pool from installation instructions; updated SAP HANA driver setup steps; removed sponsorship notes.
package.json Removed hdb-pool from dependencies; updated @sap/hana-client version constraint.
src/driver/sap/SapConnectionOptions.ts Changed default driver to @sap/hana-client; added new pool options; deprecated/removed old pool properties.
src/driver/sap/SapDriver.ts Refactored connection/pool setup; removed hdb-pool logic; added async connection methods; improved dependency loading.
src/driver/sap/SapQueryRunner.ts Refactored to use promisify and async/await for connection/query handling; improved error handling and logging.
src/platform/PlatformTools.ts Removed explicit handling for hdb-pool in dynamic module loading.
test/functional/driver/sap/connection-pool.ts Added new test suite to verify SAP HANA connection pool behavior and limits.
docs/docs/data-source/2-data-source-options.md Added documentation for new SAP HANA data source and pool configuration options.

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
Loading

Possibly related PRs

  • typeorm/typeorm#11523: Refactors async calls and error handling in the SAP driver’s disconnect method, closely related to the changes in this PR.

Poem

Hopping through code, the rabbit found
The old hdb-pool was not around.
With hana-client now at the core,
Async connections open the door.
Pooling is sleek, the docs are neat—
SAP HANA’s journey is now complete!
🐇✨

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

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error https://github.com/npm/cli/issues
npm error A complete log of this run can be found in: /.npm/_logs/2025-06-26T12_58_49_123Z-debug-0.log


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d34179d and 15fb3e9.

📒 Files selected for processing (4)
  • src/driver/sap/SapConnectionOptions.ts (1 hunks)
  • src/driver/sap/SapDriver.ts (7 hunks)
  • src/driver/sap/SapQueryRunner.ts (7 hunks)
  • test/functional/driver/sap/connection-pool.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • test/functional/driver/sap/connection-pool.ts
  • src/driver/sap/SapConnectionOptions.ts
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/driver/sap/SapDriver.ts (2)
src/platform/PlatformTools.ts (2)
  • error (267-269)
  • PlatformTools (17-279)
src/error/TypeORMError.ts (1)
  • TypeORMError (1-17)
⏰ Context from checks skipped due to timeout of 90000ms (20)
  • GitHub Check: tests-linux (20) / sap
  • GitHub Check: tests-linux (20) / oracle
  • GitHub Check: tests-linux (20) / postgres (17-3.5)
  • GitHub Check: tests-linux (20) / postgres (14-3.5)
  • GitHub Check: tests-linux (20) / sqljs
  • GitHub Check: tests-linux (20) / mongodb
  • GitHub Check: tests-linux (20) / mysql_mariadb
  • GitHub Check: tests-linux (18) / mssql
  • GitHub Check: tests-linux (18) / postgres (14-3.5)
  • GitHub Check: tests-linux (20) / better-sqlite3
  • GitHub Check: tests-linux (20) / mssql
  • GitHub Check: tests-linux (18) / oracle
  • GitHub Check: tests-linux (18) / sap
  • GitHub Check: tests-linux (18) / sqljs
  • GitHub Check: tests-linux (18) / postgres (17-3.5)
  • GitHub Check: tests-linux (18) / mysql_mariadb
  • GitHub Check: tests-windows / better-sqlite3
  • GitHub Check: tests-windows / sqljs
  • GitHub Check: tests-windows / sqlite
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (15)
src/driver/sap/SapQueryRunner.ts (6)

1-1: LGTM - Import addition supports async modernization.

The addition of promisify import from Node.js utilities correctly supports the modernization effort to replace callback-based patterns with async/await.


179-182: LGTM - Query logging and promisification added.

Good addition of query logging for the autocommit statement and proper use of promisify for the exec call, improving observability and async handling consistency.


277-290: LGTM - Proper error handling for identity value retrieval.

The try-catch block correctly handles potential errors during identity value retrieval and throws appropriate QueryFailedError with proper context.


312-312: LGTM - Statement cleanup promisified.

Good consistency in using promisify for the statement.drop operation.


343-355: LGTM - Cleanup function improved with promisification.

The cleanup function correctly uses promisify for async operations and properly nullifies references to prevent resource leaks.


88-101: ```shell
#!/bin/bash

Locate all occurrences and definitions of poolErrorHandler in the codebase

rg -n 'poolErrorHandler' -C3


</details>
<details>
<summary>src/driver/sap/SapDriver.ts (9)</summary>

`1-1`: **Good addition of promisify import.**

The addition of `promisify` from `node:util` is appropriate for converting callback-based HANA client methods to Promise-based async operations.

---

`17-17`: **LGTM - Appropriate new imports added.**

The new imports for `View`, `InstanceChecker`, and `DriverUtils` are correctly added to support the enhanced functionality.



Also applies to: 20-20, 23-23

---

`29-30`: **LGTM - Import updates are appropriate.**

The import changes for `SapConnectionOptions` and `SapQueryRunner` align with the driver modernization.

---

`47-48`: **Property updates reflect the new pooling approach.**

The property changes correctly reflect the shift from `hdb-pool` to native `@sap/hana-client` pooling with proper error handling.



Also applies to: 52-55, 62-64

---

`295-299`: **Pool option configuration looks correct.**

The conditional assignment of `pingCheck` and `poolCapacity` options has been properly implemented to avoid the previous duplicate condition issue.

---

`302-309`: **Pool error handler initialization is well-implemented.**

The error handler initialization with fallback to a default logger-based handler is appropriate for error management.

---

`342-355`: **Disconnect method has improved error handling.**

The disconnect method now properly handles the pool lifecycle with error handling through the `poolErrorHandler`. The null check and promisified `clear` call are implemented correctly.

---

`357-383`: **New async connection methods are well-implemented.**

The new `obtainMasterConnection()` and `obtainSlaveConnection()` methods properly handle async connection acquisition with appropriate error handling and TypeORM error types.

---

`873-892`: **Dependency loading has been simplified and improved.**

The refactored `loadDependencies()` method now properly prioritizes a provided client driver and handles the loading of both the main client and streaming extension with appropriate error handling.

</details>

</blockquote></details>

</details>
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKNwSPbABsvkCiQBHbGlcSHFcLzpIACIAMxJqAApENG4ASi5sRA9cWA8MakkPWgoivlj8PiYMcjF4fCxufHwveAwiaMg5SCzKdC9HDB023ApF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BoBQcsQIMMtDWgCBQwx+WIItBWgMAjoZ0NaEDhdBA5gwJAIMBeLxgMKRFAgWgEDlByg5loAgI6MaCOgbQAwXCtABtHByaKSAR0AQMdFiCg41oJANaEGHEVA4rFoOAhQYAYUmIgwG0eRUoADCLRaAy0UQHrhIACAGAUi0MGgEWhHQeFoYIMPYtByahNFkwZxUoqIVrQpFaAUMGtGWhA4+FbC0MMtCDChgVoR0IRbEAYABggla0HhbEFDAkANox0aRbUsWguK3FG0WILQDWhHRFoqizhRosWgMA2lzCkgItCByLQNFQOAQGwsmClKyl2SmpaTGSUQAugQOWxSMo4U+LWl3CgMMtFaVBggcm0YMGIr6Xg4gwKgWgAGHiCahmlRCgMAICRyLRWlDAUMOYt6VnRWlsQAMOor2W0BRFtAIMLUshxbLQwZStAB4AWVQB/FMEoMItC2UCBoVvi0MBtGWjg4+l/CzhbEHUUGKMlQOMpeIqOhHRloVyxZe0uMXQrvF2K95RtDQABgXQx0KlRtCBxaI+lK0EgAYqRw6LoVQOQlVAA4WxABANi4MNEpDDGhgwy0G5WtBUCg5mFDABRZqA2jfLeFgoWILEEUVwLXFRCpobgFIU/4KFABKhbQHNhEwCFQAA -->

<!-- internal state end -->
<!-- finishing_touch_checkbox_start -->

<details open="true">
<summary>✨ Finishing Touches</summary>

- [ ] <!-- {"checkboxId": "7962f53c-55bc-4827-bfbf-6a18da830691"} --> 📝 Generate Docstrings

</details>

<!-- finishing_touch_checkbox_end -->
<!-- tips_start -->

---

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

<details>
<summary>❤️ Share</summary>

- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)
- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)
- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)
- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)

</details>

<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=typeorm/typeorm&utm_content=11520):

- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
  - `I pushed a fix in commit <commit_id>, please review it.`
  - `Explain this complex logic.`
  - `Open a follow-up GitHub issue for this discussion.`
- Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples:
  - `@coderabbitai explain this code block.`
  -	`@coderabbitai modularize this function.`
- PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
  - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.`
  - `@coderabbitai read src/utils.ts and explain its main purpose.`
  - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.`
  - `@coderabbitai help me debug CodeRabbit configuration file.`

### Support

Need help? Create a ticket on our [support page](https://www.coderabbit.ai/contact-us/support) for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

### CodeRabbit Commands (Invoked using PR comments)

- `@coderabbitai pause` to pause the reviews on a PR.
- `@coderabbitai resume` to resume the paused reviews.
- `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
- `@coderabbitai full review` to do a full review from scratch and review all the files again.
- `@coderabbitai summary` to regenerate the summary of the PR.
- `@coderabbitai generate docstrings` to [generate docstrings](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR.
- `@coderabbitai generate sequence diagram` to generate a sequence diagram of the changes in this PR.
- `@coderabbitai resolve` resolve all the CodeRabbit review comments.
- `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository.
- `@coderabbitai help` to get help.

### Other keywords and placeholders

- Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed.
- Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description.
- Add `@coderabbitai` anywhere in the PR title to generate the title automatically.

### CodeRabbit Configuration File (`.coderabbit.yaml`)

- You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository.
- Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json`

### Documentation and Community

- Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->

@alumni alumni marked this pull request as draft June 10, 2025 23:17
@pkg-pr-new
Copy link

pkg-pr-new bot commented Jun 10, 2025

typeorm-sql-js-example

npm i https://pkg.pr.new/typeorm/typeorm@11520

commit: 15fb3e9

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 timeout

SAP 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 function and 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 the finally block never re-throws.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 86f12c9 and 3d5ee1e.

⛔ Files ignored due to path filters (2)
  • package-lock.json is excluded by !**/package-lock.json
  • sample/playground/package-lock.json is 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-client version ranges.
devDependencies now require ^2.23.27 while peerDependencies allow ^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.json

Length of output: 720


Peer and Dev dependency ranges are aligned
The devDependencies range ^2.23.27 (>=2.23.27 <3.0.0) is fully contained within the peerDependencies range ^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 a QueryRunner after a failed connect() 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, connection undefined but flagged), a second connect() 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.fulfilled

This eliminates any reliance on driver behaviour after a rejected connect().

src/driver/sap/SapQueryRunner.ts (1)

271-287: Handle empty result when querying CURRENT_IDENTITY_VALUE()

If the insert happened into a table without an identity column (or the driver
returns []), identityValueResult[0] throws. Return undefined (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 = identityValueResult
src/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-client instead of the deprecated hdb-pool.


27-28: Proper deprecation notice with clear migration path.

The deprecation notice correctly directs users to use the driver property 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 promisify import from Node.js built-in util module 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

@alumni alumni force-pushed the feature/sap-connection-pooling branch 4 times, most recently from 60ca58e to f7bd211 Compare June 11, 2025 00:35
@alumni
Copy link
Collaborator Author

alumni commented Jun 11, 2025

@coderabbitai full review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 11, 2025

✅ Actions performed

Full review triggered.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 – replace lessThanOrEqual with at.most

Same 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 without await. 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 check

The 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 closed

The 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 sections

A 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

  1. sslValidateCertificate should be wrapped in back-ticks (like the other keys)
  2. “For example, true.” – the comma after example is a stray punctuation mark.
  3. 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, cert and ca for the encrypted conne...

(UNLIKELY_OPENING_PUNCTUATION)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 86f12c9 and f7bd211.

⛔ Files ignored due to path filters (2)
  • package-lock.json is excluded by !**/package-lock.json
  • sample/playground/package-lock.json is 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 good

Switching from Promise.reject to a synchronous throw inside an async method 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 unpredictably

The 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 – LGTM

The new synchronous throw standardises error handling across drivers and keeps semantics intact.

src/driver/oracle/OracleDriver.ts (1)

346-348: Consistent error handling – looks good

Mirrors the pattern adopted for the other drivers; behaviour remains unchanged for callers.

src/driver/postgres/PostgresDriver.ts (1)

588-590: Switch to synchronous throw is correct and stylistically cleaner

Inside an async function, throw still results in a rejected Promise, 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 extra return branch. ✅

src/driver/sqlserver/SqlServerDriver.ts (1)

333-335: Consistent error propagation across drivers

Same rationale as in PostgresDriver: the synchronous throw keeps 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 good

Switching from returning a rejected promise to throwing the ConnectionIsNotSetError aligns 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 cleanup

The 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 – LGTM

The 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 improvement

Renaming 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-client versions

The 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] version returns 2.23.27, so the version exists in the registry.
  • The sandbox npm audit check returned no advisories for hana-client (empty advisories), but it ran without installing the package.
  • Please verify locally by running:
    npm install @sap/[email protected]
    npm audit
    and confirm there are no critical vulnerabilities.
  • 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 167

src/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 QueryFailedError with appropriate context. The async/await pattern improves readability.


308-308: Good async handling for statement cleanup.

Using promisify with await ensures 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 hanaClientDriver properly guides users to the driver property, 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 createPool method.


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.

@alumni alumni force-pushed the feature/sap-connection-pooling branch from f7bd211 to dec84e8 Compare June 11, 2025 01:05
@alumni alumni marked this pull request as ready for review June 11, 2025 01:38
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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, cert and ca in 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, cert and ca for the encrypted conne...

(UNLIKELY_OPENING_PUNCTUATION)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f7bd211 and dec84e8.

⛔ Files ignored due to path filters (2)
  • package-lock.json is excluded by !**/package-lock.json
  • sample/playground/package-lock.json is 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)

@alumni alumni force-pushed the feature/sap-connection-pooling branch from dec84e8 to 332a036 Compare June 11, 2025 15:12
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 from hdb-pool need these details.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~552-~552: Loose punctuation mark.
Context: ...tificate. For example, true. - key, cert and ca for the encrypted conne...

(UNLIKELY_OPENING_PUNCTUATION)

🧹 Nitpick comments (3)
src/driver/sap/SapDriver.ts (2)

329-336: disconnect() swallows clear errors

pool.clear can reject (network hiccup).
Because master is 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 skips streamClient loading

When a consumer supplies a custom driver, streamClient stays undefined, yet later code may rely on it (e.g., BLOB streaming).
Either document that a custom driver must also expose .Stream or 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 tweak

A 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, cert and ca for the encrypted conne...

(UNLIKELY_OPENING_PUNCTUATION)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dec84e8 and 332a036.

⛔ Files ignored due to path filters (2)
  • package-lock.json is excluded by !**/package-lock.json
  • sample/playground/package-lock.json is 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: obtainMasterConnection leaks on handler failure

If pool.getConnection succeeds but this.poolErrorHandler later 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

maxPooledIdleTime expects seconds, we pass milliseconds for old option

You 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 to maxPooledIdleTime and 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.

@alumni alumni force-pushed the feature/sap-connection-pooling branch from 332a036 to d4fd357 Compare June 11, 2025 15:34
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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-client

This 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 issue

Pool errors are never surfaced – attach the handler

this.poolErrorHandler is 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-options

The bullet merely says “pool – Options for the connection pool.” Please enumerate maxConnectedOrPooled, 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

timeoutMs conveys its unit, while longQueryTimeSec / shortQueryTimeSec do too – consider renaming timeoutMs to timeoutMsqueryTimeoutMs or dropping the suffix for consistency.

src/driver/sap/SapDriver.ts (2)

329-336: Safe-guard pool.clear invocation

promisify(pool.clear) will throw if pool.clear is 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: obtainMasterConnection leaks connection on error path

When getConnection succeeds, caller is responsible for release().
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 ca lacks back-ticks individually;
– Consider aligning true/false examples (truetrue) for consistency.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~552-~552: Loose punctuation mark.
Context: ...tificate. For example, true. - key, cert and ca for the encrypted conne...

(UNLIKELY_OPENING_PUNCTUATION)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 332a036 and d4fd357.

⛔ Files ignored due to path filters (2)
  • package-lock.json is excluded by !**/package-lock.json
  • sample/playground/package-lock.json is 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)

@alumni alumni force-pushed the feature/sap-connection-pooling branch from d4fd357 to b2e3271 Compare June 18, 2025 15:34
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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-client officially expects
serverNode, uid, pwd, databaseName, …
Using host, user, password, database relies 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.

poolErrorHandler is 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, cert and ca for the encrypted connection.” → “key, cert, and ca for the encrypted connection.” (add the serial comma).

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d4fd357 and b2e3271.

⛔ Files ignored due to path filters (1)
  • package-lock.json is 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)

@coveralls
Copy link

coveralls commented Jun 18, 2025

Coverage Status

coverage: 76.381% (+0.02%) from 76.363%
when pulling 15fb3e9 on alumni:feature/sap-connection-pooling
into 5904ac3 on typeorm:master.

@alumni alumni force-pushed the feature/sap-connection-pooling branch from b2e3271 to 9b2274f Compare June 18, 2025 16:32
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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-client property names (serverNode, uid, pwd, databaseName)

The driver still builds connectionOptions with 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: Pool error events are still not surfaced

The 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: Deprecated hanaClientDriver option keeps sneaking back in

SapConnectionOptions was refactored to drop hanaClientDriver, yet loadDependencies() 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:

  1. Remove the fallback to options.hanaClientDriver, or
  2. 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 new sap section

Markdown-lint flags the sub-list for pool options (+ minor loose comma).
Align all bullets two spaces under their parent and add a serial comma after ca.

- -   `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 MD007 and the LanguageTool warning.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b2e3271 and 9b2274f.

⛔ Files ignored due to path filters (1)
  • package-lock.json is 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)

@alumni alumni force-pushed the feature/sap-connection-pooling branch from 9b2274f to 6ecee87 Compare June 19, 2025 19:27
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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, and database which 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 maxPooledIdleTime is provided directly versus converted from idleTimeout.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9b2274f and 6ecee87.

⛔ Files ignored due to path filters (1)
  • package-lock.json is 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 promisify and 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 loadDependencies method properly prioritizes explicit driver options and provides clear fallback behavior with appropriate error handling.

@alumni alumni force-pushed the feature/sap-connection-pooling branch from 6ecee87 to 6c6cbcb Compare June 23, 2025 14:35
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 nested pool options list

Markdown-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

📥 Commits

Reviewing files that changed from the base of the PR and between 6ecee87 and d34179d.

⛔ Files ignored due to path filters (1)
  • package-lock.json is 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 for maxPooledIdleTime

The docs state the value is in seconds, but SAP HANA Client’s PoolOptions API expects the time in milliseconds (maxPooledIdleTime vs. idleTimeout).
Please verify the unit used in SapDriver and update the wording or example accordingly — otherwise users may unknowingly set an idle timeout 1000× longer than intended.

@alumni alumni force-pushed the feature/sap-connection-pooling branch from d34179d to 15fb3e9 Compare June 26, 2025 12:57
Copy link
Collaborator

@gioboa gioboa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏 @alumni

Copy link
Collaborator

@sgarner sgarner left a 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 = {
Copy link
Collaborator

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? 😞

Copy link
Collaborator Author

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:

  1. 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).
  2. 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.

Copy link
Collaborator

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.

Copy link
Collaborator Author

@alumni alumni Jul 1, 2025

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.

Copy link
Collaborator

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).

Tree shaking isn't necessary, this is a TSC feature:

image

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.

@alumni
Copy link
Collaborator Author

alumni commented Jul 1, 2025

I saw some config deprecations but I assume the pooling functionality is equivalent. So this is safe to include in a minor release, right?

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.

@alumni alumni merged commit aebc7eb into typeorm:master Jul 1, 2025
58 checks passed
@alumni alumni deleted the feature/sap-connection-pooling branch July 1, 2025 21:55
Copy link
Collaborator

@gioboa gioboa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏

ThbltLmr pushed a commit to ThbltLmr/typeorm that referenced this pull request Dec 2, 2025
* feat(sap): use the native driver for connection pooling

* Add pool error handler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SAP HANA: hdb-pool is deprecated - should use standard connection pooling

5 participants