1
0
forked from Yara724/api

YARA-1056

This commit is contained in:
SepehrYahyaee
2026-07-11 13:16:14 +03:30
parent 7a3ddcc7be
commit 54ae82aa38
2 changed files with 8 additions and 3 deletions

View File

@@ -32,12 +32,17 @@ export class CaptchaChallengeService {
this.captchaService.normalizeAnswer(generated.text),
);
// expireAt is the MongoDB TTL sentinel. The TTL reaper fires every ~60 s, so
// setting it equal to expiresAt means Mongo can delete the document up to 60 s
// BEFORE the application-level expiry check runs — causing the intermittent
// "captchaId not found" error under load. Adding a 120 s grace buffer ensures
// the document is always present when verify() runs its own expiresAt check.
await this.captchaChallengeDbService.create({
captchaId,
answerHash,
image: generated.image,
expiresAt: generated.expiresAt,
expireAt: new Date(generated.expiresAt),
expireAt: new Date(generated.expiresAt + 120_000),
usedAt: null,
});