The download of the mongodb binary is corrupted when using a hoisted dependency in a monorepo
oddball opened this issue · 4 comments
Versions
- NodeJS: v20.12.1
- mongodb-memory-server: 9.2.0
- mongodb(the binary version): 6.0.14
- mongodb(the js package): 6.6.1
- system: MacOS and Linux
package: mongo-memory-server
What is the Problem?
The download of the mongodb binary is corrupted when using a hoisted dependency in a monorepo
We have a mono repo.
When I have a repo/packages/auth/package.json and do
> cd repo/packages/auth
> npm i
> npm test
# works fine
> ls -lah ~/.cache/mongodb-binaries/mongod-x64-darwin-6.0.14
-rwxr-xr-x 1 oddball staff 124M May 16 15:56 /Users/oddball/.cache/mongodb-binaries/mongod-x64-darwin-6.0.14
When I have a repo/package.json to where I host the dependencies
> rm -rf ~/.cache/mongodb-binaries/
> cd repo
> npm i
> cd packages/auth
> npm test
...
Downloading MongoDB "6.0.14": 47.3% (28.4mb / 60.1)...
...
MongoMS:MongoMemoryServer Mongo[unknown]: _startUpInstance threw a Error: Error: spawn Unknown system error -88
...
# mongodb does not start
# looking at the downloaded binary:
ls -lah ~/.cache/mongodb-binaries/mongod-x64-darwin-6.0.14
-rwxr-xr-x 1 oddball staff 43M May 17 10:03 /Users/oddball/.cache/mongodb-binaries/mongod-x64-darwin-6.0.14
# We can see that it is to small! it should be 124 MB and is only 43M (and size differs every time)
If I copy a working mongod-x64-darwin-6.0.14 to ~/.cache/mongodb-binaries/ the tests works fine
to confirm, you are using package mongodb-memory-server
(no suffix like -core
or -global
), correct?
are you using any custom configuration (environment variables MONGOMS_
or config.mongodbMemoryServer
in a package.json or inside the .create
call)?
i just tired to reproduce this (on linux), and could not get it.
Could you provide a reproduction repository?
I am using mongodb-memory-server, no suffix
No MONGOMS_ variables
I will make a repo that reproduce it. Might take a day..
While creating a repo to reproduce this, I found out that everything is my fault.
I had a
jest.setTimeout(7000);
in a file, and in the hoisted case, it stopped the download before finishing, making the binary corrupt.
In the other case it ran into a
jest.setTimeout(30000);
first, and all was fine.
Sorry for the noise