Print an error when index creation fails #4064
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Thank you for LibreChat,
While investigating some performance issues, we found that some indexes were missing from MongoDB. We still don't know exactly what is the reason that we are missing indexes and are investigating. But one thing I came across was that Mongoose will only report some index failures if you explicitly do it https://mongoosejs.com/docs/guide.html#indexes
For example, if you apply this diff which adds an invalid index, to the default branch, the system will work as expected and no information about the invalid index will be visible in the logs.
With the logging added in this PR, we will see errors like this
I think in the long run having the system error and exit when an index is not able to be created is the best behaviour, but initially adding logging show what is missing is useful.
I'm happy to extend this PR to include functionality to exit, but I wanted to bring this case to your attention before making assumptions about the right way to handle the inability to create an index.
Change Type
Testing
It is described above
Checklist