generated from coulomb/repo-seed
Load limiting safeguards
This commit is contained in:
@@ -3,7 +3,7 @@ title: UI Feedback
|
||||
---
|
||||
|
||||
```js
|
||||
import {API, POLL} from "./components/config.js";
|
||||
import {API, POLL_HEAVY, apiFetch, pollDelay, sleep} from "./components/config.js";
|
||||
```
|
||||
|
||||
```js
|
||||
@@ -47,10 +47,11 @@ function nextStep(current) {
|
||||
|
||||
```js
|
||||
const feedbackState = (async function*() {
|
||||
let failures = 0;
|
||||
while (true) {
|
||||
let data = [], ok = false;
|
||||
try {
|
||||
const r = await fetch(`${API}/technical-debt/?debt_type=dashboard-improvement`);
|
||||
const r = await apiFetch("/technical-debt/?debt_type=dashboard-improvement");
|
||||
ok = r.ok;
|
||||
if (ok) {
|
||||
const items = await r.json();
|
||||
@@ -62,8 +63,9 @@ const feedbackState = (async function*() {
|
||||
});
|
||||
}
|
||||
} catch {}
|
||||
failures = ok ? 0 : failures + 1;
|
||||
yield {data, ok, ts: new Date()};
|
||||
await new Promise(res => setTimeout(res, POLL));
|
||||
await sleep(pollDelay({ok, base: POLL_HEAVY, failures}));
|
||||
}
|
||||
})();
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user