New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: cyclic dependency detected - On adding text index to field #6472
Comments
@onkar0777 I tried to reproduce your issue with the following code: 6472.js#!/usr/bin/env node
'use strict';
const mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/test');
const conn = mongoose.connection;
const Schema = mongoose.Schema;
const meaningSchema = new Schema({
x: String
});
const wordSchema = new Schema({
title: {
type: String,
required: true,
},
meanings: [meaningSchema],
keys: [String],
tags: [String],
language: String,
createdAt: Date,
updatedAt: Date
});
wordSchema.index({ title: 'text' });
const Test = mongoose.model('test', wordSchema);
const test = new Test({
title: 'Hello'
});
async function run() {
await conn.dropDatabase();
await Test.ensureIndexes();
await test.save();
let found = await Test.findOne({ $text: { $search: 'Hello' } });
console.log(found);
return conn.close();
}
run(); Output:
This doesn't cause any errors for me. Can you either create a complete example or modify mine to mirror yours to reproduce the error? |
I am experiencing this as well. Many large models, when I comment out the ones with text indexes it works, if I comment any of them back in I get a cyclic dependency detected error. Running mongoose 5.1.1, but still have the problem back to 5.0 |
when I comment out the text parts of this index as well as the weights it works. `Hello.index(
)` also the error exists when I comment out the index: true of the following:
|
@onkar0777 @AugustBrenner can you check out #6109, are you by chance using the retryWrites option on your connection? |
Should be fixed by #6109 |
Do you want to request a feature or report a bug? Bug
What is the current behavior? Unable to start server because of the error. Error logs:
If the current behavior is a bug, please provide the steps to reproduce.
Creating a text index on my field gives this error. Code:
What is the expected behavior?
Should work without errors
Please mention your node.js, mongoose and MongoDB version.
node - 9.11.1
mongoose - 5.1.1 (same with 5.0.8)
MongoDB - 3.6.2
The text was updated successfully, but these errors were encountered: