Skip to content

DX | 03-08-2026 | Release - #242

Draft
reeshika-h wants to merge 16 commits into
mainfrom
development
Draft

DX | 03-08-2026 | Release#242
reeshika-h wants to merge 16 commits into
mainfrom
development

Conversation

@reeshika-h

@reeshika-h reeshika-h commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

v1.5.0

harshitha-cstk and others added 16 commits May 25, 2026 13:54
chore: back-merge main into development
chore: back-merge main into development
retryResponseErrorHandler threw a plain object literal (error_message/error_code
fields, no .message) for axios ECONNABORTED (client-side timeout) errors.
APIError.fromAxiosError only recognizes .response.data, .request, or .message,
so the plain object matched none of those and collapsed to a generic
UNKNOWN_ERROR/status:0 - indistinguishable from a true network-layer failure,
with no indication the request had actually timed out.

Throw a real Error with .message and .code set instead, so it flows through
the existing err.message branch in fromAxiosError and surfaces as a distinct,
diagnosable TIMEOUT (408) error.

DX-9991
No longer needed now that the ECONNABORTED branch throws a real Error
instead of a plain object literal.

DX-9991
The default retryCondition only ever matched HTTP 429, so any network-level
failure (DNS resolution failure, connection reset, client-side timeout) with
no HTTP response got zero retries out of the box, even though the retry
mechanism to handle them already existed and was already tested (retrying
via a custom retryCondition already worked).

Add a default retryCondition fallback covering ECONNABORTED, ETIMEDOUT,
ECONNRESET, EPIPE, and EAI_AGAIN (DNS transient failure) when there is no
response - deliberately excluding ENOTFOUND and ECONNREFUSED, which usually
indicate a persistent misconfiguration rather than a transient blip.

Placed in delivery-sdk-handlers.ts's own defaultConfig rather than
contentstack-core.ts's httpClient defaults, since retryResponseErrorHandler
is invoked with the raw StackConfig (see contentstack-typescript's
stack/contentstack.ts), not client.defaults - a retryCondition set only on
the axios instance defaults never reaches the actual retry decision.
Verified against the real call pattern, not just isolated unit tests.

DX-9991
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
…andling

fix: classify request timeouts distinctly instead of unknown error
Merging development (with the timeout classification fix) surfaced an
interaction: the classification test didn't set retryCondition, so it now
picks up the new default retryCondition (which retries ECONNABORTED),
taking the retry path instead of the classification path it was meant to
test. Same fix as already applied to the other pre-existing ECONNABORTED
test - explicitly disable retryCondition to isolate the behavior under test.

DX-9991
…rrors

fix: retry transient network errors by default
…ction-pooling

Default to keep-alive agents in Node environments for better performance
Bundles the three DX-9991 fixes: timeout classification, default retry
for transient network errors, and default keep-alive connection agents.

DX-9991
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.

2 participants