SLow down requests for development
This commit is contained in:
parent
6da107ff3a
commit
a2cbcf0519
1 changed files with 99 additions and 0 deletions
14
frontend/obsidian-plugin/src/debugging/slow-fetch-factory.ts
Normal file
14
frontend/obsidian-plugin/src/debugging/slow-fetch-factory.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
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…
Reference in a new issue