Skip to content
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

Package doesn't download correct 4.0.x version for win32 #399

Closed
bhsi3h opened this issue Oct 6, 2020 · 15 comments · Fixed by #400
Closed

Package doesn't download correct 4.0.x version for win32 #399

bhsi3h opened this issue Oct 6, 2020 · 15 comments · Fixed by #400
Labels
bug Module: Version-String Generation This problem is because of the Version-String Generation (MongoBinaryDownloadUrl) released on @beta released Pull Request released | Issue is fixed

Comments

@bhsi3h
Copy link

bhsi3h commented Oct 6, 2020

Versions

  • NodeJS: v10.16.0
  • mongodb-memory-server-*: 5.2.11
  • mongodb: 3.2.7
  • jest: 23.6.0
  • system: Windows

package: mongo-memory-server

What is the Problem?

The Gitlab CI fails by having creating a new instance of mongodb-memory-server. This is for unit testing, and I have only imported the package into the file.

Gitlab CI Error Below:

  Use debug option for more info: new MongoMemoryServer({ debug: true })
  at /node_modules/mongodb-memory-server-core/src/MongoMemoryServer.ts:87:17
  console.error node_modules/jest-jasmine2/build/jasmine/Env.js:157
    Unhandled error
  console.error node_modules/jest-jasmine2/build/jasmine/Env.js:158
    Error: Cannot read property 'toString' of undefined

Code Example

import { MongoMemoryServer } from 'mongodb-memory-server';

jest.setTimeout(60000);

describe('access', () => {
  let test: MongoMemoryServer;

  beforeAll(async() => {
    test = new MongoMemoryServer();
  });

  it('Should throw error', () => {
    let result = false;
    expect(result).toEqual(false);
  });

  afterAll((done: DoneFn) => {
    test.stop().then((result) => {
      done();
    });
  });
  
});

Do you know why it happenes?

no

@bhsi3h bhsi3h added the bug label Oct 6, 2020
@hasezoey
Copy link
Collaborator

hasezoey commented Oct 7, 2020

if possible, please upgrade to 6.9.0 and re-post the error if it still happens

and if the error still happens, please also provide the full debug log

@bhsi3h
Copy link
Author

bhsi3h commented Oct 7, 2020

if possible, please upgrade to 6.9.0 and re-post the error if it still happens

and if the error still happens, please also provide the full debug log

Package updated to 6.9.0 and updated mongodb to 3.6.2. and receiving the following error (included debug):

2020-10-07T15:33:25.737Z MongoMS:MongoMemoryServer Called MongoMemoryServer.ensureInstance() method
2020-10-07T15:33:25.737Z MongoMS:MongoMemoryServer  - no running instance, call `start()` command
2020-10-07T15:33:25.738Z MongoMS:MongoMemoryServer Called MongoMemoryServer.start() method
2020-10-07T15:33:25.744Z MongoMS:MongoMemoryServer starting with port 38431, since undefined was locked: 38431
2020-10-07T15:33:25.746Z MongoMS:MongoMemoryServer Starting MongoDB instance with following options: {"port":38431,"dbName":"17dbde06-cfdd-4e75-bc37-7591b80c22f6","ip":"127.0.0.1","storageEngine":"ephemeralForTest","dbPath":"/tmp/mongo-mem--88-LgpC8aWimPZE","tmpDir":{"name":"/tmp/mongo-mem--88-LgpC8aWimPZE"},"uri":"mongodb://127.0.0.1:38431/17dbde06-cfdd-4e75-bc37-7591b80c22f6?"}
2020-10-07T15:33:25.750Z MongoMS:MongoBinary MongoBinary options: {
  "downloadDir": "/builds/node_modules/.cache/mongodb-memory-server/mongodb-binaries",
  "platform": "linux",
  "arch": "x64",
  "version": "4.0.14",
  "checkMD5": false
}
NODE_ENV values of test detected. Assuming this is done automatically by Jest. Using empty config object.
2020-10-07T15:19:16.217Z MongoMS:MongoBinary MongoBinary: Download lock removed
2020-10-07T15:19:16.217Z MongoMS:MongoBinary MongoBinary: Mongod binary path: "/builds/node_modules/.cache/mongodb-memory-server/mongodb-binaries/4.0.14/mongod"
2020-10-07T15:19:16.352Z MongoMS:MongoMemoryServer Called MongoMemoryServer.stop() method
2020-10-07T15:19:16.352Z MongoMS:MongoMemoryServer Called MongoMemoryServer.ensureInstance() method
2020-10-07T15:19:16.355Z MongoMS:MongoInstance Mongo[40835]: MongodbInstance: Instance has failed: Error: spawn /builds/node_modules/.cache/mongodb-memory-server/mongodb-binaries/4.0.14/mongod ENOENT
2020-10-07T15:19:16.371Z MongoMS:MongoInstance Mongo[40835]: Mongod instance closed with an non-0 code!
2020-10-07T15:19:16.371Z MongoMS:MongoInstance Mongo[40835]: CLOSE: -2
2020-10-07T15:19:16.371Z MongoMS:MongoInstance Mongo[40835]: MongodbInstance: Instance has failed: Mongod instance closed with code "-2"

    Error: Spawned Mongo Instance PID is undefined
        at MongoInstance.Object.<anonymous>.MongoInstance._launchMongod (/builds/node_modules/mongodb-memory-server-core/src/util/MongoInstance.ts:235:13)

@hasezoey
Copy link
Collaborator

hasezoey commented Oct 7, 2020

@bhsi3h the log says it all, the file this package tries to execute dosnt exist, ENOENT

you installed package mongo-memory-server, correct? if yes, then this package should have downloaded the correct mongod file on package-install (npm install / yarn install) to local node_modules/ - did you skip it or did it error?

@bhsi3h
Copy link
Author

bhsi3h commented Oct 7, 2020

@bhsi3h the log says it all, the file this package tries to execute dosnt exist, ENOENT

you installed package mongo-memory-server, correct? if yes, then this package should have downloaded the correct mongod file on package-install (npm install / yarn install) to local node_modules/ - did you skip it or did it error?

Just went through the response when I ran the install command, it did give back the error:

failed to download/install MongoDB binaries. The error: Error: Status Code is 403 (MongoDB's 404)
This means that the requested version-platform combination doesn't exist
  Used Url: "https://fastdl.mongodb.org/win32/mongodb-win32-x86_64-4.0.14.zip"
Try to use different version 'new MongoMemoryServer({ binary: { version: 'X.Y.Z' } })'

I will try downloading it and reporting back

@hasezoey
Copy link
Collaborator

hasezoey commented Oct 7, 2020

is your problem maybe related / the same as #55 ? (especially: #55 (comment))

PS: does http://downloads.mongodb.org/win32/mongodb-win32-x86_64-2008plus-ssl-4.0.14.zip work?

EDIT: you can overwrite the download link temporary with MONGOMS_DOWNLOAD_URL=url

@bhsi3h
Copy link
Author

bhsi3h commented Oct 7, 2020

is your problem maybe related / the same as #55 ? (especially: #55 (comment))

PS: does http://downloads.mongodb.org/win32/mongodb-win32-x86_64-2008plus-ssl-4.0.14.zip work?

EDIT: you can overwrite the download link temporary with MONGOMS_DOWNLOAD_URL=url

The link works. I did take a look at the cache dir and it seemed like it didn't download everything it needed from the original link.

Pardon me, but how would I run the command to overwrite the download link?

@hasezoey
Copy link
Collaborator

hasezoey commented Oct 7, 2020

basicly MONGOMS_DOWNLOAD_URL=url npm i (or use cross-env (package))

@hasezoey
Copy link
Collaborator

hasezoey commented Oct 7, 2020

so basicly this is an duplicate of what was said in #55 (comment) , right?

(i will leave this open, because #55 is already old and closed)

@hasezoey hasezoey changed the title Gitlab CI Reports Unhandled Error followed by Cannot read property 'toString' of undefined Package doesn't download correct 4.0.x version for win32 Oct 7, 2020
@hasezoey hasezoey added the Module: Version-String Generation This problem is because of the Version-String Generation (MongoBinaryDownloadUrl) label Oct 7, 2020
@hasezoey
Copy link
Collaborator

hasezoey commented Oct 7, 2020

@bhsi3h @austi10 can you confirm #400 fixes this issue?

Edit: reformat: can you confirm 6.9.1 fixes this issue?

@github-actions
Copy link

github-actions bot commented Oct 7, 2020

@github-actions github-actions bot added the released Pull Request released | Issue is fixed label Oct 7, 2020
@bhsi3h
Copy link
Author

bhsi3h commented Oct 7, 2020

@hasezoey I just reinstalled 6.9.1. I am not getting that 403 error anymore but still receiving ENOENT on Gitlab CI Pipeline. My issue may be pointing something else.

@hasezoey
Copy link
Collaborator

hasezoey commented Oct 7, 2020

if you dont get an install error anymore, then the pipeline shouldnt fail

the pipeline runs on linux right? ... what is the full error? (maybe put that into an new issue, if not releated)

@bhsi3h
Copy link
Author

bhsi3h commented Oct 7, 2020

Yeah the Pipeline runs on Linux. It spins up a docker image with Alpine. Maybe Alpine has issue with Mongodb? I will put into new issue if its out of scope.

Debug turned off

NODE_ENV values of test detected. Assuming this is done automatically by Jest. Using empty config object.
  console.warn node_modules//dist/config/default.js:7
    NODE_ENV values of test detected. Assuming this is done automatically by Jest. Using empty config object.
  console.warn node_modules/mongodb-memory-server-core/lib/MongoMemoryServer.js:143
    Starting the instance failed, please enable debug for more infomation
  console.error node_modules/jest-jasmine2/build/jasmine/Env.js:157
    Unhandled error
  console.error node_modules/jest-jasmine2/build/jasmine/Env.js:158
    Error: Spawned Mongo Instance PID is undefined
        at MongoInstance.Object.<anonymous>.MongoInstance._launchMongod (/builds/node_modules/mongodb-memory-server-core/src/util/MongoInstance.ts:235:13)
        at MongoInstance.<anonymous> (/builds/node_modules/mongodb-memory-server-core/src/util/MongoInstance.ts:140:30)
        at step (/builds/mongodb-memory-server-core/lib/util/MongoInstance.js:44:23)
        at Object.next (/builds/node_modules/mongodb-memory-server-core/lib/util/MongoInstance.js:25:53)
        at fulfilled (/builds/node_modules/mongodb-memory-server-core/lib/util/MongoInstance.js:16:58)
  console.error node_modules/jest-jasmine2/build/jasmine/Env.js:157
    Unhandled error
  console.error node_modules/jest-jasmine2/build/jasmine/Env.js:158
    Error: spawn /builds/node_modules/.cache/mongodb-memory-server/mongodb-binaries/latest/mongod ENOENT
        at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
        at onErrorNT (internal/child_process.js:415:16)
        at process._tickCallback (internal/process/next_tick.js:63:19)
FAIL spec/dataAccess.spec.ts (61.278s)

Conifg

  "config": {
    "mongodbMemoryServer": {
      "version": "latest"
    }
  }

@hasezoey
Copy link
Collaborator

hasezoey commented Oct 7, 2020

@bhsi3h yes, Alpine is the issue, look into #347 for more

@github-actions
Copy link

github-actions bot commented Nov 1, 2020

🎉 This issue has been resolved in version 7.0.0-beta.8 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Module: Version-String Generation This problem is because of the Version-String Generation (MongoBinaryDownloadUrl) released on @beta released Pull Request released | Issue is fixed
Projects
None yet
2 participants