Skip to content

feat(sap): add pool timeout - #11868

Merged
alumni merged 1 commit into
typeorm:v0.3from
alumni:feat/sap-pool-timeout
Jan 3, 2026
Merged

alumni merged 1 commit into
typeorm:v0.3from
alumni:feat/sap-pool-timeout

Conversation

@alumni

@alumni alumni commented Dec 22, 2025

Copy link
Copy Markdown
Collaborator

Description of change

Fixes #11619.

Adds support for the maxWaitTimeoutIfPoolExhausted pool option (available in @sap/hana-client version 2.27 or later) and maps the deprecated requestTimeout from the old hdb-pool library to this option.

Pull-Request Checklist

  • Code is up-to-date with the v0.3 branch
  • This pull request links relevant issues as Fixes #00000
  • There are new or updated tests validating the change (tests/**.test.ts)
  • Documentation has been updated to reflect this change (docs/docs/**.md)

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Fallback Logic

The fallback from maxWaitTimeoutIfPoolExhausted to requestTimeout may cause issues if requestTimeout is undefined or if users have both options set. Consider whether the deprecated option should take precedence or if there should be a warning when both are specified.

maxWaitTimeoutIfPoolExhausted:
    this.options.pool?.maxWaitTimeoutIfPoolExhausted ??
    this.options.pool?.requestTimeout,
Unrelated Change

The Docker image update and command reordering appear unrelated to the PR's stated purpose of adding pool timeout support. This change should be verified as intentional or moved to a separate PR.

image: "saplabs/hanaexpress:2.00.088.00.20251110.1"
container_name: "typeorm-hanaexpress"
hostname: hxe
command:
  [
    "--agree-to-sap-license",
    "--passwords-url",
    "file:////hana/hxe-config.json",

@alumni
alumni changed the base branch from master to v0.3 December 22, 2025 21:57
@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Dec 22, 2025 •

Copy link
Copy Markdown

PR Code Suggestions ✨

Latest suggestions up to 75d3fd4

CategorySuggestion                                                                                                                                    Impact
Possible issue
Validate timeout value is non-negative

Add validation to ensure the maxWaitTimeoutIfPoolExhausted option is a
non-negative number, throwing an error if the provided value is invalid.

src/driver/sap/SapDriver.ts [294-297]

-maxWaitTimeoutIfPoolExhausted:
-    this.options.pool?.maxWaitTimeoutIfPoolExhausted ??
-    this.options.pool?.requestTimeout ??
-    0,
+maxWaitTimeoutIfPoolExhausted: (() => {
+    const timeout = this.options.pool?.maxWaitTimeoutIfPoolExhausted ??
+        this.options.pool?.requestTimeout ??
+        0;
+    if (timeout < 0) {
+        throw new TypeORMError(
+            "maxWaitTimeoutIfPoolExhausted must be a non-negative number"
+        );
+    }
+    return timeout;
+})(),
  • Apply / Chat
Suggestion importance[1-10]: 5

__

Why: The suggestion correctly points out that a timeout value should not be negative. Adding this validation improves the driver's robustness by catching configuration errors early.

Low
  • More

Previous suggestions

Suggestions up to commit 3243e1b
CategorySuggestion                                                                                                                                    Impact
General
Validate pool timeout is non-negative

Ensure the maxWaitTimeoutIfPoolExhausted option is non-negative by using
Math.max() to prevent potential errors from invalid configuration.

src/driver/sap/SapDriver.ts [294-297]

-maxWaitTimeoutIfPoolExhausted:
+maxWaitTimeoutIfPoolExhausted: Math.max(
+    0,
     this.options.pool?.maxWaitTimeoutIfPoolExhausted ??
     this.options.pool?.requestTimeout ??
-    0,
+    0
+),
Suggestion importance[1-10]: 6

__

Why: The suggestion correctly identifies that a negative timeout value is invalid and could cause issues. Applying Math.max(0, ...) is a simple and effective way to sanitize the user-provided configuration and improve the driver's robustness.

Low
Suggestions up to commit c933de8
CategorySuggestion                                                                                                                                    Impact
General
Improve fallback logic for pool timeout

For setting maxWaitTimeoutIfPoolExhausted, replace the nullish coalescing
operator (??) with a more explicit ternary operator checking for undefined to
improve clarity when falling back to the deprecated requestTimeout.

src/driver/sap/SapDriver.ts [294-296]

 maxWaitTimeoutIfPoolExhausted:
-    this.options.pool?.maxWaitTimeoutIfPoolExhausted ??
-    this.options.pool?.requestTimeout,
+    this.options.pool?.maxWaitTimeoutIfPoolExhausted !== undefined
+        ? this.options.pool.maxWaitTimeoutIfPoolExhausted
+        : this.options.pool?.requestTimeout,
Suggestion importance[1-10]: 2

__

Why: The suggestion correctly notes that the existing code with the nullish coalescing operator (??) works as intended, but proposes a more verbose ternary operator for readability, which is a subjective style preference with no functional benefit.

Low

@gioboa gioboa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM @alumni 🚀

@alumni alumni changed the title Feat/sap pool timeout feat(sap): add pool timeout Dec 22, 2025
* Defines the maximum time, in milliseconds, to wait for a connection
* to become available once the specified number of `maxConnectedOrPooled`
* open connections have been reached (default: 0, no wait).
* @remarks Requires `@sap/hana-client` version `2.27` or later.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@pkuczynski FYI, seems the linting rules are not aware of the @remarks TSDoc tag and they won't be implementing it either: gajus/eslint-plugin-jsdoc#1381 🤷🏻

@alumni
alumni force-pushed the feat/sap-pool-timeout branch from c933de8 to 3243e1b Compare December 22, 2025 22:24
@pkg-pr-new

pkg-pr-new Bot commented Dec 22, 2025 •

Copy link
Copy Markdown
  • typeorm-sql-js-example

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

commit: 75d3fd4

@gioboa
gioboa requested review from G0maa and naorpeled December 25, 2025 10:13
@alumni
alumni requested a review from sgarner December 30, 2025 21:59
@alumni
alumni force-pushed the feat/sap-pool-timeout branch from 3243e1b to 75d3fd4 Compare December 30, 2025 23:18
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 80.766% (-0.003%) from 80.769%
when pulling 75d3fd4 on alumni:feat/sap-pool-timeout
into 5153436 on typeorm:v0.3.

@alumni
alumni requested a review from OSA413 January 2, 2026 22:20
@alumni
alumni merged commit b4e2ad2 into typeorm:v0.3 Jan 3, 2026
gioboa pushed a commit to gioboa/typeorm that referenced this pull request Jan 13, 2026
gioboa pushed a commit to gioboa/typeorm that referenced this pull request Jan 13, 2026
mgohin pushed a commit to mgohin/typeorm that referenced this pull request Jan 15, 2026
kranners pushed a commit to kranners/typeorm that referenced this pull request Mar 1, 2026
@pkuczynski pkuczynski added this to the 1.0 milestone Mar 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

SAP Hana Connection Pooling is broken since 0.3.26

6 participants