Move more logic into sync-client
This commit is contained in:
parent
3f089bd37e
commit
9177984ff6
20 changed files with 68 additions and 143 deletions
16
frontend/sync-client/src/debugging/slow-fetch-factory.ts
Normal file
16
frontend/sync-client/src/debugging/slow-fetch-factory.ts
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import { sleep } from "../utils/sleep";
|
||||
|
||||
export const slowFetchFactory =
|
||||
(jitterScaleInSeconds: number) =>
|
||||
async (
|
||||
input: string | URL | globalThis.Request,
|
||||
init?: RequestInit
|
||||
): Promise<Response> => {
|
||||
if (jitterScaleInSeconds > 0) {
|
||||
await sleep(Math.random() * jitterScaleInSeconds * 1000);
|
||||
}
|
||||
|
||||
const response = await fetch(input, init);
|
||||
|
||||
return response;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue