Skip to content

Commit

Permalink
chore: update buffered request to split each request
Browse files Browse the repository at this point in the history
  • Loading branch information
bang9 committed Dec 6, 2022
1 parent 391d3cd commit b03c996
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions packages/uikit-utils/src/shared/bufferedRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,15 @@ export class BufferedRequest {
}
}, timeoutMills + SAFE_TIMEOUT_BUFFER);

nextQueue.forEach(async (func, lane) => {
try {
await func();
} catch (e) {
waitQueue.set(lane, func);
}
let index = 0;
const nextRequestBaseTimeout = timeoutMills / nextQueue.size;
nextQueue.forEach((func) => {
setTimeout(() => {
func();
// TODO: Add retry
//.catch(() => waitQueue.set(lane, func));
}, nextRequestBaseTimeout * index);
index++;
});
nextQueue.clear();
},
Expand Down

0 comments on commit b03c996

Please sign in to comment.