mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 00:40:14 +01:00
chore: clear timeouts
This commit is contained in:
parent
bff33c79b3
commit
7afe09fa02
1 changed files with 7 additions and 1 deletions
|
|
@ -2,6 +2,7 @@ const mongoose = require('mongoose');
|
|||
const Conversation = mongoose.models.Conversation;
|
||||
const Message = mongoose.models.Message;
|
||||
const { MeiliSearch } = require('meilisearch');
|
||||
let currentTimeout = null;
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
async function indexSync(req, res, next) {
|
||||
|
|
@ -46,7 +47,7 @@ async function indexSync(req, res, next) {
|
|||
// console.log('in index sync');
|
||||
if (err.message.includes('not found')) {
|
||||
console.log('Creating indices...');
|
||||
setTimeout(async () => {
|
||||
currentTimeout = setTimeout(async () => {
|
||||
try {
|
||||
await Message.syncWithMeili();
|
||||
await Conversation.syncWithMeili();
|
||||
|
|
@ -61,4 +62,9 @@ async function indexSync(req, res, next) {
|
|||
}
|
||||
}
|
||||
|
||||
process.on('exit', () => {
|
||||
console.log('Clearing sync timeouts before exiting...');
|
||||
clearTimeout(currentTimeout);
|
||||
});
|
||||
|
||||
module.exports = indexSync;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue