Skip to content

Commit

Permalink
Cap the number of revalidation requests
Browse files Browse the repository at this point in the history
Refs 6b527e3
  • Loading branch information
thewilkybarkid committed Oct 3, 2024
1 parent e87ccdb commit 23fc566
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ export function revalidateIfStale<E extends F.FetchEnv & SleepEnv>(): (env: E) =
fetch: async (url, init) => {
const response = await env.fetch(url, init)

if (response.headers.get('x-local-cache-status') === 'stale' && !openRequests.has(url)) {
if (
response.headers.get('x-local-cache-status') === 'stale' &&
openRequests.size <= 200 &&
!openRequests.has(url)
) {
openRequests.add(url)

void env
Expand Down

0 comments on commit 23fc566

Please sign in to comment.