Does not work with Node.js v16
crobinson42 opened this issue · 13 comments
This package only works with Node.js v12 & v14.
Here is the error in Node.js v16 environment:
> npx jest
Starting the instance failed, enable debug for more information
Error: Jest: Got error running globalSetup - /domain-impl-server/node_modules/@shelf/jest-mongodb/setup.js, reason: Instance Exited before being ready and without throwing an error!
at MongoInstance.<anonymous> (/domain-impl-server/node_modules/@shelf/jest-mongodb/node_modules/mongodb-memory-server-core/lib/util/MongoInstance.js:134:25)
at Object.onceWrapper (node:events:514:26)
at MongoInstance.emit (node:events:394:28)
at MongoInstance.closeHandler (/domain-impl-server/node_modules/@shelf/jest-mongodb/node_modules/mongodb-memory-server-core/lib/util/MongoInstance.js:275:14)
at ChildProcess.emit (node:events:394:28)
at maybeClose (node:internal/child_process:1067:16)
at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
This error originates from MongoDB Memory Server
Maybe it's better to open issue in that repo instead
@vladgolubev how about we bump mongodb-memory-server to the latest version 7.3.6 in this package and give it a test to see if that solves the issue. If that doesn't work then we can open an issue upstream in that repo 👍
@crobinson42 fair assumption. Check out https://github.com/shelfio/jest-mongodb/releases/tag/v2.0.2 with the latest version of mongodb-memory-server
@vladgolubev I have verified v2.0.2 works with node v16.
There is an impending PR that should be merge also to make the package fully compatible [up to date] with node v16: #290 perhaps you can merge and bump to v2.0.3? 🙏
@crobinson42 sure, here it is https://github.com/shelfio/jest-mongodb/releases/tag/v2.0.3
Thanks, the latest version solved the problem on node v16.
It works locally, however, I'm still seeing this issue in the CI environment:
> jest
Starting the instance failed, enable debug for more information
Error: Jest: Got error running globalSetup - /opt/atlassian/pipelines/agent/build/node_modules/@shelf/jest-mongodb/setup.js, reason: Instance Exited before being ready and without throwing an error!
Neither version 2.0.3 nor 2.1.0 solves this problem for me. I have the same problem as @crobinson42. Tests pass locally, but in CI using the node:16.11.1 image they fail with the above error.
This issue should be reopened and tracked. My group has several projects that can't update to Node v16 until this is fixed or a workaround is found.
Thank you @crobinson42! I'm trying to track down what might be missing. The big change from node 14 to node 16 on dockerhub is the base OS changed from Debian 9 (stretch) to Debian 10 (buster). I have not tried with any of the Debian 11 (bullseye) images just yet. Looking through the FROM lines I see no difference in packages explicitly installed from the buildpack-deps version (buster-curl, buster-scm, buster vs. stretch-curl, stretch-scm, and stretch).
I have no idea what package/library is bad/wrong/missing/etc. I'll make sure to post my notes here when I hit upon a solution (I would love to use your image, but it would break the invariant that a local build and the CI build use the same version of Mongo, we are stuck at 4.0.X as many developers are on OS X).
Turning on MONGOMS_DEBUG inside the container and manually running the tests gives the following error when trying to use the mongodb binary:
stderrHandler: ""/home/node/.cache/mongodb-binaries/mongod-x64-debian-4.0.25: /usr/lib/x86_64-linux-gnu/libcurl.so.4: version `CURL_OPENSSL_3' not found (required by /home/node/.cache/mongodb-binaries/mongod-x64-debian-4.0.25)
This is really a nail in the coffin for using Mongo 4.0.X as Node 16 images default to Buster and you cannot install libcurl3 with SSL support in Debian 10 or 11 (dropped support for SSLv1.0 which is what MongoDB 4.0.X is looking for). If you are using MongoDB v4.4 or higher, there should be no issue with the updated libcurl4 versions.
I'm testing the node:16-stretch and node:16-stretch-slim image to see if they will work for me.
My apologies for continuing to update this closed ticket. It's clear the issue is not with the code in this repo or the code in mongo-memory-server packages. I have a feeling many people will run onto this in the not-too-distant future and maybe this issue can save them some work.
Ultimately using the stretch
image did work out. I was not able to make the stretch-slim
image work. Both the node:16-stretch
image and the node:16.11.1-stretch
image worked for me.