fix: add jitter to user cache

This commit is contained in:
yanlong.wang 2025-04-01 15:05:12 +08:00
parent 988413dc6b
commit f3b82a4d50
No known key found for this signature in database
GPG Key ID: C0A623C0BADF9F37

View File

@ -105,10 +105,11 @@ export class JinaEmbeddingsAuthDTO extends AutoCastable {
}
const age = account?.lastSyncedAt ? Date.now() - account.lastSyncedAt.getTime() : Infinity;
const age = account?.lastSyncedAt ? Date.now() - account.lastSyncedAt.valueOf() : Infinity;
const jitter = Math.ceil(Math.random() * 30 * 1000);
if (account && !ignoreCache) {
if (account && age < 180_000) {
if (account && age < (180_000 - jitter)) {
this.user = account;
this.uid = this.user?.user_id;