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

Launch timeout triggers during lazy download #719

Closed
Jomshir98 opened this issue Nov 25, 2022 · 2 comments
Closed

Launch timeout triggers during lazy download #719

Jomshir98 opened this issue Nov 25, 2022 · 2 comments
Labels
bug released Pull Request released | Issue is fixed

Comments

@Jomshir98
Copy link

Versions

  • NodeJS: v18.12.1
  • mongodb-memory-server-core: 8.10.0
  • system: Tested on multiple platforms (Win+Linux)

package: mongo-memory-server-core

What is the Problem?

When mongodb binary isn't already downloaded, the launch timeout triggers during the download process

Code Example

return await MongoMemoryServer.create({
	binary: {
		version: '5.0.6',
		checkMD5: false,
	},
	instance: {
		args: ['--setParameter', 'diagnosticDataCollectionEnabled=false'],
	},
});

Debug Output

Instance failed to start within 10000ms

Do you know why it happens?

Yes: Timeout created at

const launch: Promise<void> = new Promise<void>((res, rej) => {
this.once(MongoInstanceEvents.instanceReady, res);
this.once(MongoInstanceEvents.instanceError, rej);
this.once(MongoInstanceEvents.instanceClosed, function launchInstanceClosed() {
rej(new Error('Instance Exited before being ready and without throwing an error!'));
});
// extra conditions just to be sure that the custom defined timeout is valid
const timeoutTime =
!!this.instanceOpts.launchTimeout && this.instanceOpts.launchTimeout >= 1000
? this.instanceOpts.launchTimeout
: 1000 * 10; // default 10 seconds
timeout = setTimeout(() => {
const err = new GenericMMSError(`Instance failed to start within ${timeoutTime}ms`);
this.emit(MongoInstanceEvents.instanceError, err);
rej(err);
}, timeoutTime);
}).finally(() => {
// always clear the timeout after the promise somehow resolves
clearTimeout(timeout);
});
const mongoBin = await MongoBinary.getPath(this.binaryOpts);
await checkBinaryPermissions(mongoBin);
this.debug('start: Starting Processes');

starts before call to await MongoBinary.getPath(this.binaryOpts); (which lazy-downloads the binary), meaning the timeout times out during slow download too.
Fix could be moving await MongoBinary.getPath(this.binaryOpts); before the timeout start.

@hasezoey
Copy link
Collaborator

thanks for reporting, didnt consider this - version should be published in ~10min as 8.10.1

@github-actions
Copy link

@github-actions github-actions bot added the released Pull Request released | Issue is fixed label Nov 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug released Pull Request released | Issue is fixed
Projects
None yet
Development

No branches or pull requests

2 participants