-
-
Notifications
You must be signed in to change notification settings - Fork 186
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
Does it work with mongodb 4? #89
Comments
@YuriGor Did you specified your mongodb version with the env variable MONGOMS_VERSION ? |
No, I used default constructor parameter like this: var mongod = new MongodbMemoryServer.default({
instance: {
dbName: 'slug',
},
binary: {
version: '3.6.3',
},
}); here is my test script: |
In your test script, didn't you forgot to add a await keyword to this line ? mongoose.connect(
mongoUri,
{ useNewUrlParser: true },
); If you don't wait this Promise to resolve, you will not be able to do a schema.create() after I think and it might explain why the process exits. |
connect is synchronous method It has a callback function parameter to handle errors, and I added one: I also tried to add 'await' also with no success. |
@YuriGor Where do you see that is a synchronous method ? In the mongoose documentation, it is specified that is a Promise that is returned so it suggests that is a asynchronous operation.
So there is certainly a problem in the connection with a 4.0 mongodb binary and you couldn't catch it. |
it stop at line |
I tried your code with the version 4.0.3 of mongodb and it worked, I had this output : pre-update defined with default(?) options/ 66.8mb)
pre-update defined by regex with default(?) options
mondo connected
I'll be updated soon
-----------------
default preupdate!
default this looks good
-----------------
default regex preupdate!
default regex this looks good
(node:79695) DeprecationWarning: collection.update is deprecated. Use updateOne, updateMany, or bulkWrite instead.
I was updated! Edit : I just saw you were on ubuntu, I'm on mac so I will give it a try with a ubuntu docker image ! |
oh wow, regex hook works too! for me it doesn't I have latest MongoDB already installed on my machine, can it conflict with one started by mongodb-memory-server? |
I have the same output with version 3.6.3 ! But like I specified before I'm running on mac os, I will try it on a ubuntu distrib. |
I tried to remove mngodb instalation, rebooted, but has same issue. |
It works fine directly with mongo 4.0.3 |
Ok, i had an old Mongoose version, that's why regex didn't work, but there is still a problem with mongodb-memory-server, it can't run mongodb 4.0.3 |
Here is isolated test script for this issue |
I had the same issue unexpectedly. My tests kept failing as I didn't specify the Mongodb version to 3.6.x. Apparently it used the 4.x version which never passed |
@YuriGor @floric update to the latest package version and try to run following code: const MongodbMemoryServer = require('mongodb-memory-server').default;
async function main(v) {
try {
console.log(v);
console.log('--> b4 new MongodbMemoryServer.default..');
var config = {
instance: {
dbName: 'run',
},
binary: {
version: v,
},
debug: true,
};
const mongod = new MongodbMemoryServer(config);
console.log('--> b4 mongod.getConnectionString()..');
const mongoUri = await mongod.getConnectionString();
console.log(
`[!] If you see this, then mongodb-memory-server works with mongo ${config.binary.version}`
);
await mongod.stop();
console.log(`stop ${config.binary.version}`);
} catch (err) {
console.error(`Something wrong with ${config.binary.version}`, err);
}
}
main('4.0.0')
.then(() => {
return main('4.0.1');
})
.then(() => {
return main('4.0.2');
})
.then(() => {
return main('4.0.3');
})
.catch(err => {
console.log('oh noes');
}); It will output debug information which helps to resolve your issue. |
I confirm that it works with mongodb v4 on macOS, also it works on ubuntu 14.04 (travis CI). |
WIll have a look later. FYI currently, I don't need Mongodb 4.x. It just happened by accident as the version was bumped. But I'll stick to Db 3.6 for now :) Thanks anyway. |
I ran your script and found error
so I tried to But how did standalone installed MongoDB work without installed libcurl3? |
@YuriGor can you take care about it and make PR? We cannot install libcurl3 but may provide proper error message. |
Ok, but not very soon. |
I just noticed that binaries archive files downloaded into .mongodb-binaries folder has names like this: I manually downloaded mongodb-linux-x86_64-ubuntu1804-4.0.3.tgz from https://www.mongodb.com/download-center/community and replaced So mongodb-memory-server needs to choose correctly which binaries to download considering current OS version. |
I believe this versions list should be updated: |
@YuriGor great catch!!! |
Issue solved with #96 so I close it. |
Latest working version of mongo I tried is 3.6.3
When I try latest or 4.0.0/1/2/3 - it downloads binaries and then silently exits the process
(K)Ubuntu 18.04
Node v10.7.0
mongodb-memory-server 2.4.3
The text was updated successfully, but these errors were encountered: