Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## [v1.4.0](https://github.com/contentstack/contentstack-marketplace-sdk/tree/v1.3.0) (2024-08-25)
- Enhancement: Retry logic to make use of x-ratelimit-remaining header

## [v1.3.0](https://github.com/contentstack/contentstack-marketplace-sdk/tree/v1.3.0) (2024-08-11)
- Enh: Add search function to query apps by names

Expand All @@ -9,6 +12,7 @@
- Added Pre-commit hook to run the snyk and talismand scans

## [v1.2.8](https://github.com/contentstack/contentstack-marketplace-sdk/tree/v1.2.8) (2024-05-26)

- Fix: Added params support to getInstalledApps method for enhanced flexibility

## [v1.2.7](https://github.com/contentstack/contentstack-marketplace-sdk/tree/v1.2.7) (2024-05-15)
Expand Down
35 changes: 24 additions & 11 deletions lib/core/concurrency-queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,19 +202,32 @@ export function ConcurrencyQueue ({ axios, config }) {
} else {
return Promise.reject(responseHandler(error))
}
} else if (response.status === 429 || (response.status === 401 && this.config.refreshToken)) {
retryErrorType = `Error with status: ${response.status}`
networkError++
} else {
const rateLimitRemaining = response.headers['x-ratelimit-remaining']
if (rateLimitRemaining !== undefined && parseInt(rateLimitRemaining) <= 0) {
// return Promise.reject(responseHandler(error))

if (networkError > this.config.retryLimit) {
return Promise.reject(responseHandler(error))
this.running.shift()
return delay(wait).then(() => {
error.config.retryCount = networkError++
// deepcode ignore Ssrf: URL is dynamic
return axios(updateRequestConfig(error, 'Rate Limit Hit', wait))
})
}
if (response.status === 429 || (response.status === 401 && this.config.refreshToken)) {
retryErrorType = `Error with status: ${response.status}`
networkError++

if (networkError > this.config.retryLimit) {
return Promise.reject(responseHandler(error))
}
this.running.shift()
// Cool down the running requests
delay(wait, response.status === 401)
error.config.retryCount = networkError
// deepcode ignore Ssrf: URL is dynamic
return axios(updateRequestConfig(error, retryErrorType, wait))
}
this.running.shift()
// Cool down the running requests
delay(wait, response.status === 401)
error.config.retryCount = networkError
// deepcode ignore Ssrf: URL is dynamic
return axios(updateRequestConfig(error, retryErrorType, wait))
}
if (this.config.retryCondition && this.config.retryCondition(error)) {
retryErrorType = error.response ? `Error with status: ${response.status}` : `Error Code:${error.code}`
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@contentstack/marketplace-sdk",
"version": "1.3.0",
"version": "1.4.0",
"description": "The Contentstack Marketplace SDK is used to manage the content of your Contentstack marketplace apps",
"main": "./dist/node/contentstack-marketplace.js",
"browser": "./dist/web/contentstack-marketplace.js",
Expand Down
Loading