Skip to content

Default to keep-alive agents in Node environments for better performance - #241

Draft
reeshika-h wants to merge 2 commits into
developmentfrom
fix/DX-9991-keepalive-connection-pooling
Draft

Default to keep-alive agents in Node environments for better performance#241
reeshika-h wants to merge 2 commits into
developmentfrom
fix/DX-9991-keepalive-connection-pooling

Conversation

@reeshika-h

Copy link
Copy Markdown
Contributor

No description provided.

httpAgent/httpsAgent defaulted to false, so every request opened a fresh
TCP/TLS connection with zero reuse - relevant under Next.js prerendering
concurrency, where redundant connection setup adds latency that pushes
more requests toward the request timeout.

Default to a keepAlive http.Agent/https.Agent instead, guarded behind a
Node-only runtime check (typeof window === 'undefined', matching the
existing isBrowser() convention in contentstack-typescript) since
@contentstack/core has no browser field to redirect Node-only imports
away from browser bundles the way axios does for itself.

A fresh agent is created per httpClient() call rather than a shared
module-level singleton - a deliberate tradeoff to avoid shared state
across separate stack() instances in the same process.

No behavior change for callers who already set their own httpAgent/
httpsAgent (including explicit false), and no behavior change at all in
browser environments.

DX-9991
Removes duplication between the httpAgent and httpsAgent defaults.

DX-9991
@github-actions

Copy link
Copy Markdown

🔒 Security Scan Results

ℹ️ Note: Only vulnerabilities with available fixes (upgrades or patches) are counted toward thresholds.

Check Type Count (with fixes) Without fixes Threshold Result
🔴 Critical Severity 0 0 10 ✅ Passed
🟠 High Severity 0 0 25 ✅ Passed
🟡 Medium Severity 0 0 500 ✅ Passed
🔵 Low Severity 0 0 1000 ✅ Passed

⏱️ SLA Breach Summary

✅ No SLA breaches detected. All vulnerabilities are within acceptable time thresholds.

Severity Breaches (with fixes) Breaches (no fixes) SLA Threshold (with/no fixes) Status
🔴 Critical 0 0 15 / 30 days ✅ Passed
🟠 High 0 0 30 / 120 days ✅ Passed
🟡 Medium 0 0 90 / 365 days ✅ Passed
🔵 Low 0 0 180 / 365 days ✅ Passed

✅ BUILD PASSED - All security checks passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant