fix: remove .unref() from middleware setInterval (Edge Runtime incompatibility)
This commit is contained in:
@@ -68,6 +68,7 @@ function checkRateLimit(request: NextRequest): { allowed: boolean; limit: number
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Periodically clean up stale buckets (every 5 minutes)
|
// Periodically clean up stale buckets (every 5 minutes)
|
||||||
|
// Edge Runtime cleanup (no .unref support)
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
for (const [key, bucket] of buckets.entries()) {
|
for (const [key, bucket] of buckets.entries()) {
|
||||||
@@ -75,7 +76,7 @@ setInterval(() => {
|
|||||||
buckets.delete(key);
|
buckets.delete(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 300000).unref();
|
}, 300000);
|
||||||
|
|
||||||
// ── Excluded routes ──────────────────────────────────────────────────────────────
|
// ── Excluded routes ──────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user