Skip to content

Commit 33024a8

Browse files
committed
fix: rate-limit failfast
1 parent 3980c33 commit 33024a8

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

infrastructure/evault-core/src/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,11 @@ const initializeEVault = async (
186186
const ip = request.ip;
187187
const { allowed, retryAfterSeconds } = checkGlobalRateLimit(token, ip);
188188
if (!allowed) {
189-
reply
189+
// In an async onRequest hook, Fastify only short-circuits the
190+
// handler chain if you return the reply object. Without the
191+
// return, the 429 is queued but the downstream handler (GraphQL)
192+
// still runs — turning the rate limiter into a silent counter.
193+
return reply
190194
.code(429)
191195
.header("Retry-After", String(retryAfterSeconds))
192196
.send({

0 commit comments

Comments
 (0)