Skip to content

fix(DX-10060): retry transient network errors to prevent build crashes - #385

Draft
OMpawar-21 wants to merge 4 commits into
developmentfrom
fix/DX-10060
Draft

fix(DX-10060): retry transient network errors to prevent build crashes#385
OMpawar-21 wants to merge 4 commits into
developmentfrom
fix/DX-10060

Conversation

@OMpawar-21

@OMpawar-21 OMpawar-21 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Transient network-layer errors (ENOTFOUND, ENETUNREACH, ECONNRESET, ECONNREFUSED, EAI_AGAIN, ETIMEDOUT, EHOSTUNREACH, ENETDOWN) are now retried using the SDK's configured retry policy instead of failing immediately.
  • A combinedRetryCondition composes any user-supplied retryCondition with the new default network-error check — the user condition runs first, the original config is never mutated.
  • If the user-supplied retryCondition throws, a warning is emitted via logHandler and the SDK falls back to default retry behaviour.
  • ECONNABORTED is intentionally excluded — @contentstack/core classifies it as a structured TIMEOUT error.
  • Version bumped 5.5.05.6.0 (minor — crux retry logic changed).

Test coverage

8 unit tests added covering: ENOTFOUND retry, ENETUNREACH/ETIMEDOUT (customer-reported codes), EAI_AGAIN, ECONNRESET composition with user retryCondition, ECONNABORTED exclusion, retryOnError: false, and retryLimit: 0.

🤖 Generated with Claude Code

OMpawar-21 and others added 2 commits July 31, 2026 16:39
Transient network-layer errors (ENOTFOUND, ENETUNREACH, ECONNRESET,
ECONNREFUSED, EAI_AGAIN, ETIMEDOUT, EHOSTUNREACH, ENETDOWN) now trigger
the SDK's configured retry policy instead of failing immediately.

A combinedRetryCondition composes the user-supplied retryCondition with
the new default network-error check. The user condition runs first; if it
throws, a warning is emitted via logHandler and the SDK falls back to the
default. The original config object is never mutated.

ECONNABORTED is excluded — @contentstack/core classifies it as a
structured TIMEOUT error and handles it separately.

Resolves: SF Case #00060601 (SentinelOne)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@OMpawar-21
OMpawar-21 requested a review from a team as a code owner August 3, 2026 05:17
@snyk-io

snyk-io Bot commented Aug 3, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

Coverage report

St.
Category Percentage Covered / Total
🟢 Statements
98.8% (-0.09% 🔻)
992/1004
🟢 Branches
95.87% (-0.57% 🔻)
302/315
🟢 Functions
97.79% (+0.02% 🔼)
221/226
🟢 Lines
99.37% (+0.01% 🔼)
945/951
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟢
... / contentstack.ts
95.56% (-0.87% 🔻)
93.88% (-3.95% 🔻)
84.62% (+1.28% 🔼)
96.59% (+0.21% 🔼)

Test suite run success

717 tests passing in 36 suites.

Report generated by 🧪jest coverage report action from 0d45b5b

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@OMpawar-21 OMpawar-21 self-assigned this Aug 3, 2026
@OMpawar-21
OMpawar-21 marked this pull request as draft August 3, 2026 05:47
netrajpatel
netrajpatel previously approved these changes Aug 3, 2026
…warnings

Lines 182 and 184 in contentstack.ts (the catch block and logHandler warn path)
were flagged uncovered by jest-coverage-report-action. Added test (g) which
exercises a retryCondition that throws, verifies the SDK falls back to default
retry behaviour, and asserts the warning is emitted via logHandler.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Not ready to approve

There are correctness and consistency issues in the new retry helper/documentation and logging payload that should be addressed before merging.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Pull request overview

Adds default retry behavior for transient network-layer failures in the Delivery SDK by composing a new network-error retry check with any user-provided retryCondition, and documents/releases the change as a minor version bump.

Changes:

  • Composes a combinedRetryCondition in the stack client to retry common transient network error codes while preserving the original user retryCondition reference.
  • Adds a utility helper (isTransientNetworkError) + constant set of retryable network error codes.
  • Introduces unit tests covering the new retry behavior and updates version/changelog to 5.6.0.
File summaries
File Description
test/unit/network-error-retry.spec.ts Adds unit tests validating retries for specific transient network error codes and opt-out behaviors.
src/stack/contentstack.ts Composes retry behavior with user retryCondition and adds warning logging when user logic throws.
src/common/utils.ts Adds transient network error code set and helper used by the new retry logic.
package.json Bumps SDK version to 5.6.0.
CHANGELOG.md Documents the retry behavior change and release date for 5.6.0.
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 3
  • Review effort level: Lite

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

Comment thread src/stack/contentstack.ts
Comment on lines +175 to +179
// Retry policy handlers.
// Network-layer errors (DNS failures, connection resets, etc.) are retried
// by default, composed on top of any user-supplied retryCondition. `config`
// itself is never mutated, so stack.config / client.defaults keep reflecting
// exactly what the consumer passed in.
Comment thread src/stack/contentstack.ts
Comment on lines +183 to +185
} catch (e) {
config.logHandler?.('warn', `[Contentstack SDK] retryCondition callback threw: "${(e as Error)?.message ?? e}". Check your retryCondition implementation. Falling back to default network-error retry behavior.`);
}
Comment thread src/common/utils.ts
Comment on lines +43 to +45
export function isTransientNetworkError(error: any): boolean {
return !!error && typeof error.code === 'string' && TRANSIENT_NETWORK_ERROR_CODES.has(error.code);
}
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.

3 participants