Skip to content

Commit da95c40

Browse files
Merge pull request #437 from contentstack/development
Staging PR
2 parents db4c44f + 19e0fa5 commit da95c40

File tree

6 files changed

+28
-14
lines changed

6 files changed

+28
-14
lines changed

.talismanrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ fileignoreconfig:
99
ignore_detectors:
1010
- filecontent
1111
- filename: package-lock.json
12-
checksum: c37956b0e6ccd5267dac7fd6f4347fbb5ad41defe1c42d39aaaeaf64d2cf8605
12+
checksum: bab53d56ce2609e960fdbbd1e87cc89915820e6761016ddd74ee57f931f4223d
1313
- filename: .husky/pre-commit
1414
checksum: 52a664f536cf5d1be0bea19cb6031ca6e8107b45b6314fe7d47b7fad7d800632
1515
- filename: test/sanity-check/api/user-test.js

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## [v1.25.1](https://github.com/contentstack/contentstack-management-javascript/tree/v1.25.1) (2025-10-06)
4+
- Fix
5+
- Updated delay handling to use centralized external configuration in SDK interceptor
6+
37
## [v1.25.0](https://github.com/contentstack/contentstack-management-javascript/tree/v1.25.0) (2025-09-03)
48
- Enhancement
59
- Added publish_all_localized param in bulk publish/unpublish

lib/core/concurrency-queue.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ const defaultConfig = {
1414
retryOnHttpServerError: true,
1515
maxNetworkRetries: 3,
1616
networkRetryDelay: 100, // Base delay for network retries (ms)
17-
networkBackoffStrategy: 'exponential' // 'exponential' or 'fixed'
17+
networkBackoffStrategy: 'exponential', // 'exponential' or 'fixed'
18+
delayMs: null // Delay in milliseconds before making each request
1819
}
1920

2021
export function ConcurrencyQueue ({ axios, config }) {
@@ -175,16 +176,22 @@ export function ConcurrencyQueue ({ axios, config }) {
175176

176177
// Initial shift will check running request,
177178
// and adds request to running queue if max requests are not running
178-
this.initialShift = () => {
179+
this.initialShift = async () => {
179180
if (this.running.length < this.config.maxRequests && !this.paused) {
180-
shift()
181+
await shift()
181182
}
182183
}
183184

184185
// INTERNAL: Shift the queued item to running queue
185-
const shift = () => {
186+
const shift = async () => {
186187
if (this.queue.length && !this.paused) {
187188
const queueItem = this.queue.shift()
189+
190+
// Add configurable delay before making the request if specified
191+
if (this.config.delayMs && this.config.delayMs > 0) {
192+
await new Promise(resolve => setTimeout(resolve, this.config.delayMs))
193+
}
194+
188195
queueItem.resolve(queueItem.request)
189196
this.running.push(queueItem)
190197
}
@@ -197,7 +204,7 @@ export function ConcurrencyQueue ({ axios, config }) {
197204

198205
this.push = requestPromise => {
199206
this.queue.push(requestPromise)
200-
this.initialShift()
207+
this.initialShift().catch(console.error)
201208
}
202209

203210
this.clear = () => {
@@ -312,7 +319,7 @@ export function ConcurrencyQueue ({ axios, config }) {
312319
return refreshToken()
313320
} else {
314321
for (let i = 0; i < this.config.maxRequests; i++) {
315-
this.initialShift()
322+
this.initialShift().catch(console.error)
316323
}
317324
}
318325
}, time))
@@ -360,7 +367,7 @@ export function ConcurrencyQueue ({ axios, config }) {
360367
}
361368
})
362369
for (let i = 0; i < this.config.maxRequests; i++) {
363-
this.initialShift()
370+
this.initialShift().catch(console.error)
364371
}
365372
})
366373
}

package-lock.json

Lines changed: 6 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@contentstack/management",
3-
"version": "1.25.0",
3+
"version": "1.25.1",
44
"description": "The Content Management API is used to manage the content of your Contentstack account",
55
"main": "./dist/node/contentstack-management.js",
66
"browser": "./dist/web/contentstack-management.js",
@@ -53,7 +53,7 @@
5353
"license": "MIT",
5454
"dependencies": {
5555
"assert": "^2.1.0",
56-
"axios": "^1.11.0",
56+
"axios": "^1.12.2",
5757
"buffer": "^6.0.3",
5858
"form-data": "^4.0.4",
5959
"husky": "^9.1.7",

types/contentstackClient.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export interface ContentstackConfig extends AxiosRequestConfig, ContentstackToke
4545
logHandler?: (level: string, data: any) => void
4646
application?: string
4747
integration?: string
48+
delayMs?: number
4849
}
4950

5051
export interface LoginDetails {

0 commit comments

Comments
 (0)