Comments (24)
I just noticed that binaries archive files downloaded into .mongodb-binaries folder has names like this:
mongodb-linux-x86_64-ubuntu1404-4.0.3.tgz
so this is version for Ubuntu 14.04, where libcurl3 was in use.
I manually downloaded mongodb-linux-x86_64-ubuntu1804-4.0.3.tgz from https://www.mongodb.com/download-center/community and replaced mongod
in .mongodb-binaries/4.0.3/ folder.
Now mongodb-memory-server runs Mongo v4.0.3 with default for Ubuntu 18.04 libcurl4 library installed, no need to instal libcurl3.
This is important, because libcurl3 and libcurl4 are mutually exclusive and in case libcurl3 will be installed instead of libcurl4, I expect some compatibility issues with other soft aimed to Ubuntu 18.04.
So mongodb-memory-server needs to choose correctly which binaries to download considering current OS version.
from mongodb-memory-server.
Issue solved with #96 so I close it.
Thank you for help!
from mongodb-memory-server.
@YuriGor Did you specified your mongodb version with the env variable MONGOMS_VERSION ?
from mongodb-memory-server.
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:
https://gist.github.com/YuriGor/cc8114a0d0b1ad151eaf58baab24aa3a
(actually it was created for testing possible bug in mongoose)
from mongodb-memory-server.
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.
from mongodb-memory-server.
connect is synchronous method
It has a callback function parameter to handle errors, and I added one:
https://gist.github.com/YuriGor/cc8114a0d0b1ad151eaf58baab24aa3a#file-pre-update-js-L26
but with no effect, it still works fine with 3.6 3 and stops silently with 4.0.*
I also tried to add 'await' also with no success.
from mongodb-memory-server.
@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.
But the docs also specify that if you don't wait the connect method to resolve it's Promise, you will be able to define mongoose schemas but the first operation that you will do on the database will hang on until mongoose is connected to the database and will not throw any error :
https://mongoosejs.com/docs/connections.html
Mongoose lets you start using your models immediately, without waiting for mongoose to establish a connection to MongoDB.
mongoose.connect('mongodb://localhost:27017/myapp');
var MyModel = mongoose.model('Test', new Schema({ name: String }));
// Works
MyModel.findOne(function(error, result) { /* ... */ });
That's because mongoose buffers model function calls internally. This buffering is convenient, but also a common source of confusion. Mongoose will not throw any errors by default if you use a model without connecting.
So there is certainly a problem in the connection with a 4.0 mongodb binary and you couldn't catch it.
And when you say it stops silently, where exactly in the code does it stop ?
from mongodb-memory-server.
it stop at line
const mongoUri = await mongod.getConnectionString();
so mongoose even doesn't try to connect
from mongodb-memory-server.
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 !
from mongodb-memory-server.
default regex preupdate!
default regex this looks good
oh wow, regex hook works too! for me it doesn't
and what do you see with v3.6.3?
I have latest MongoDB already installed on my machine, can it conflict with one started by mongodb-memory-server?
May be this is why older version still works, but not latest?
from 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.
from mongodb-memory-server.
I tried to remove mngodb instalation, rebooted, but has same issue.
I will try to install mongodb again and use it in this test without mongodb-memory-server's help, may be it's a mongodb issue
from mongodb-memory-server.
It works fine directly with mongo 4.0.3
but regex hooks still don't work in mongoose (wtf?)
What is your node and mongoose versions?
from mongodb-memory-server.
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
from mongodb-memory-server.
Here is isolated test script for this issue
https://gist.github.com/YuriGor/035fca75e53fd14204a3a4d44eee2f6a
I'll modify that one above to remove mongodb-memory-server and work with mongodb directly
from mongodb-memory-server.
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 client.getConnectionString()
.
from mongodb-memory-server.
@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.
from mongodb-memory-server.
I confirm that it works with mongodb v4 on macOS, also it works on ubuntu 14.04 (travis CI).
from mongodb-memory-server.
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.
from mongodb-memory-server.
I ran your script and found error
version `CURL_OPENSSL_3' not found (required by /home/gor/.mongodb-binaries/4.0.0/mongod)
4.0.0
--> b4 new MongodbMemoryServer.default..
Autostarting MongoDB instance...
--> b4 mongod.getConnectionString()..
Thu, 25 Oct 2018 16:55:34 GMT Mongo[41659] Starting MongoDB instance with following options: {"port":41659,"dbName":"run","uri":"mongodb://127.0.0.1:41659/run","storageEngine":"ephemeralForTest","dbPath":"/tmp/mongo-mem-15929Tdoexfi6klUy"}
Thu, 25 Oct 2018 16:55:34 GMT Mongo[41659] MongoBinary options: {"downloadDir":"/home/gor/.mongodb-binaries","platform":"linux","arch":"x64","version":"4.0.0"}
Thu, 25 Oct 2018 16:55:34 GMT Mongo[41659] MongoBinary: Mongod binary path: /home/gor/.mongodb-binaries/4.0.0/mongod
Thu, 25 Oct 2018 16:55:34 GMT Mongo[41659] MongoBinary: Download lock removed
Thu, 25 Oct 2018 16:55:34 GMT Mongo[41659] STDERR: /home/gor/.mongodb-binaries/4.0.0/mongod: /usr/lib/x86_64-linux-gnu/libcurl.so.4: version `CURL_OPENSSL_3' not found (required by /home/gor/.mongodb-binaries/4.0.0/mongod)
Thu, 25 Oct 2018 16:55:34 GMT Mongo[41659] CLOSE: 1
[Finished in 2.3s]
so I tried to
sudo apt-get install libcurl3
and it helped, now my tests work with version 4.0.3
But how did standalone installed MongoDB work without installed libcurl3?
Does it have this lib bundled? Then why binaries downloaded by mongodb-memory-server do not?
May be we need to show this error without debug flag too?
from mongodb-memory-server.
@YuriGor can you take care about it and make PR?
We cannot install libcurl3 but may provide proper error message.
It can be started here
from mongodb-memory-server.
Ok, but not very soon.
from mongodb-memory-server.
I believe this versions list should be updated:
lates Ubuntu version listed here is 16.04, so in case of 18.04 default 14.04 used instead.
from mongodb-memory-server.
@YuriGor great catch!!!
from mongodb-memory-server.
Related Issues (20)
- oplogSize for replSet should be removed in README HOT 2
- Use RHEL 9 binaries HOT 2
- Add Support for "Rocky Linux 9" HOT 4
- [SOLUTION] Jest and Fake Timers HOT 1
- Amazon EC2 instance download failed, combination does not exist (403) HOT 4
- "getport" sometimes throwing an error HOT 43
- DownloadError: Download failed for url "https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-5.0.19.tgz" HOT 10
- Weird "db.watch" issue HOT 1
- postinstallHelper always installs to $HOME/.cache instead of node_modules/.cache HOT 6
- Enabling debug mode through package.json does not work HOT 3
- Randomizing db names for each test
- GridFS streams not working correctly HOT 4
- Jest + mongodb-memory-server + mongoose - Calling 'find' hangs indefinitely HOT 2
- Invalid version reported for version strings ending in -latest HOT 2
- Ubuntu >= 22.04 is unsupported when using MongoDB >= 6.0.4 HOT 7
- _startUpInstance threw a Error: TypeError: (intermediate value).finally is not a function HOT 3
- Mongod instance closed with code "127" HOT 7
- Case: InMemory DB refuses to update after Making changes to model HOT 7
- Library is missing or cannot be opened: "libcrypto.so.1.1" HOT 2
- 9.1.8 not working out of the box for node:20 docker (LTS images) HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mongodb-memory-server.