mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-17 21:43:06 +00:00
🔁 fix: Build the KeyvMongo Key Index Through the Retrying Helper (#17282)
This commit is contained in:
parent
14096e7576
commit
f5569dff2c
1 changed files with 5 additions and 2 deletions
7
packages/api/src/cache/keyvMongo.ts
vendored
7
packages/api/src/cache/keyvMongo.ts
vendored
|
|
@ -1,7 +1,7 @@
|
|||
import mongoose from 'mongoose';
|
||||
import { EventEmitter } from 'events';
|
||||
import { GridFSBucket } from 'mongodb';
|
||||
import { logger } from '@librechat/data-schemas';
|
||||
import { buildIndexWithRetry, logger } from '@librechat/data-schemas';
|
||||
import type { Db, ReadPreference, Collection } from 'mongodb';
|
||||
|
||||
interface KeyvMongoOptions {
|
||||
|
|
@ -79,7 +79,10 @@ class KeyvMongoCustom extends EventEmitter {
|
|||
/** Every read and upsert filters on `key`; unindexed, each one scans the collection.
|
||||
* Built in the background, and skipped when the deployment disables auto indexing. */
|
||||
if (mongoose.connection.config?.autoIndex !== false) {
|
||||
store.createIndex({ key: 1 }).catch((error: unknown) => {
|
||||
buildIndexWithRetry(
|
||||
() => store.createIndex({ key: 1 }),
|
||||
`KeyvMongo "${collection}" key index`,
|
||||
).catch((error: unknown) => {
|
||||
logger.warn(`[KeyvMongo] Could not index "${collection}" by key`, error);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue