Skip to content
Closed
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
8 changes: 7 additions & 1 deletion saltgui/static/scripts/Api.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,9 +362,15 @@
options.body = JSON.stringify(pParams);
}

// simple client-side throttle to avoid flooding the server with rapid requests
const now = Date.now();
API._requestTimestamps = (API._requestTimestamps || []).filter((pTs) => now - pTs < 1000);
const delay = API._requestTimestamps.length >= 20 ? 1000 - (now - API._requestTimestamps[0]) : 0;
API._requestTimestamps.push(now);

/* eslint-disable compat/compat */
/* fetch is not supported in op_mini all, IE 11 */
return window.fetch(url, options).
return new Promise((pResolve) => setTimeout(pResolve, Math.max(0, delay))).then(() => window.fetch(url, options)).

Check failure on line 373 in saltgui/static/scripts/Api.js

View workflow job for this annotation

GitHub Actions / build (26.x)

'setTimeout' is not defined

Check failure on line 373 in saltgui/static/scripts/Api.js

View workflow job for this annotation

GitHub Actions / build (22.x)

'setTimeout' is not defined

Check failure on line 373 in saltgui/static/scripts/Api.js

View workflow job for this annotation

GitHub Actions / build (24.x)

'setTimeout' is not defined
/* eslint-enable compat/compat */
then((pResponse) => {
if (pResponse.ok && pPage.endsWith(".txt")) {
Expand Down
Loading