DX | 03-08-2026 | Release - #242
Draft
reeshika-h wants to merge 16 commits into
Draft
Conversation
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
…try-network-errors
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
…epalive-connection-pooling
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
v1.5.0