Skip to content

feat: add robust error handling for transient network failures #395

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: development
Choose a base branch
from

Conversation

nadeem-cs
Copy link
Contributor

No description provided.

@nadeem-cs nadeem-cs requested a review from a team as a code owner July 23, 2025 09:30
@aman19K aman19K requested a review from Copilot July 23, 2025 09:38
Copilot

This comment was marked as outdated.

@nadeem-cs nadeem-cs requested a review from aman19K July 23, 2025 11:04
Copy link

github-actions bot commented Jul 24, 2025

Coverage report for commit: dbb940b
File: coverage/clover.xml

Cover ┌─────────────────────────┐ Freq.
   0% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  10% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  20% │ ██░░░░░░░░░░░░░░░░░░░░░ │  2.3%
  30% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  40% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  50% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  60% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  70% │ ███████░░░░░░░░░░░░░░░░ │ 11.4%
  80% │ ███████████████████████ │ 38.6%
  90% │ ██████████████░░░░░░░░░ │ 22.7%
 100% │ ███████████████░░░░░░░░ │ 25.0%
      └─────────────────────────┘
 *Legend:* █ = Current Distribution 
Summary - Lines: 82.17% | Methods: 95.81% | Branches: 68.25%
FilesLinesMethodsBranches
lib
   contentstack.js83.33%100.00%84.62%
   contentstackClient.js80.85%92.86%64.15%
   contentstackCollection.js94.12%100.00%86.67%
   entity.js76.09%100.00%61.33%
lib/core
   Util.js72.41%85.71%58.16%
   concurrency-queue.js69.37%71.43%64.90%
   contentstackError.js100.00%100.00%100.00%
   contentstackHTTPClient.js96.77%100.00%93.65%
   oauthHandler.js88.81%100.00%65.99%
lib/organization
   index.js72.73%100.00%53.09%
lib/organization/teams
   index.js89.47%100.00%65.79%
lib/organization/teams/stackRoleMappings
   index.js78.57%100.00%51.16%
lib/organization/teams/teamUsers
   index.js100.00%100.00%93.75%
lib/query
   index.js73.91%100.00%61.82%
lib/stack/asset/folders
   index.js100.00%100.00%100.00%
lib/stack/asset
   index.js86.25%100.00%74.00%
lib/stack/auditlog
   index.js91.67%100.00%71.88%
lib/stack/branch
   compare.js68.18%100.00%62.50%
   index.js94.87%100.00%77.78%
   mergeQueue.js83.33%100.00%63.16%
lib/stack/branchAlias
   index.js79.31%100.00%60.98%
lib/stack/contentType/entry
   index.js83.04%100.00%59.29%
lib/stack/contentType/entry/variants
   index.js79.31%100.00%62.86%
lib/stack/contentType
   index.js84.62%100.00%70.13%
lib/stack/deliveryToken
   index.js95.24%80.00%89.47%
lib/stack/deliveryToken/previewToken
   index.js21.43%25.00%14.29%
lib/stack/environment
   index.js100.00%100.00%100.00%
lib/stack/extension
   index.js93.88%100.00%85.71%
lib/stack/globalField
   index.js91.67%100.00%82.35%
lib/stack
   index.js80.66%92.86%70.61%
lib/stack/label
   index.js100.00%100.00%100.00%
lib/stack/locale
   index.js100.00%100.00%100.00%
lib/stack/managementToken
   index.js100.00%100.00%94.44%
lib/stack/release
   index.js86.67%100.00%68.09%
lib/stack/roles
   index.js100.00%100.00%100.00%
lib/stack/taxonomy
   index.js84.00%100.00%61.29%
lib/stack/taxonomy/terms
   index.js84.62%100.00%66.67%
lib/stack/variantGroup
   index.js81.58%100.00%60.47%
lib/stack/variantGroup/variants
   index.js77.50%100.00%54.90%
lib/stack/variants
   index.js76.32%100.00%53.19%
lib/stack/webhook
   index.js84.48%100.00%67.80%
lib/stack/workflow
   index.js83.64%100.00%67.69%
lib/stack/workflow/publishRules
   index.js100.00%100.00%100.00%
lib/user
   index.js91.43%100.00%78.57%

🤖 comment via lucassabreu/comment-coverage-clover

@nadeem-cs nadeem-cs requested review from aman19K and Copilot July 24, 2025 12:30
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds robust error handling for transient network failures to the Contentstack SDK, implementing enhanced retry mechanisms with exponential backoff and fine-grained control over different types of network errors. The changes include comprehensive retry logic for DNS failures, socket errors, timeouts, and HTTP server errors, along with SSRF protection for URL validation.

Key changes include:

  • Enhanced retry configuration with network-specific retry options (DNS, socket, HTTP 5xx errors)
  • Exponential backoff strategy with jitter for network retries
  • SSRF protection through URL validation utilities

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
lib/core/concurrency-queue.js Implements core network retry logic with transient error detection and enhanced retry mechanisms
lib/core/Util.js Adds URL validation utilities for SSRF prevention
test/unit/concurrency-Queue-test.js Updates test cases to handle new retry configuration and error handling patterns
examples/robust-error-handling.js Provides comprehensive examples of the new error handling configuration options
.talismanrc Adds security scanning exemption for the new example file
Comments suppressed due to low confidence (2)

lib/core/concurrency-queue.js:328

  • The retry condition check for error.response.status === 408 may fail for timeout errors that don't have a response object. This could cause the retry mechanism to not work properly for ECONNABORTED timeout errors that are later transformed to have a 408 status.
        this.config.authorization = token.authorization

test/unit/concurrency-Queue-test.js:352

  • The test assertion expects at least 2 log calls but doesn't verify the specific retry behavior or validate that the correct retry logic was triggered. Consider adding more specific assertions about retry attempts and error types.
      expect(logHandlerStub.callCount).to.be.at.least(2) // Should have retry attempts

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