Skip to content
This repository has been archived by the owner on Jan 3, 2023. It is now read-only.

mongodb config does not seem to wait for the connection to resolve #253

Closed
eddyystop opened this issue Jul 30, 2017 · 5 comments
Closed

Comments

@eddyystop
Copy link

The relevent code in src/services/monododb.js is

  const config = app.get('mongodb');
  const promise = MongoClient.connect(config);
  app.set('mongoClient', promise);

My test apparently used a mongodb service before the connection was established. It looks like it threw because app.service(...) was undefined. It did not throw once I delayed the test with a setTimeout.

I think the main concern is that an app using mongodb may sometimes boot and sometimes not.

@daffl
Copy link
Member

daffl commented Jul 30, 2017

I think adding something like

before(() => app.get('mongoClient'));

In the tests should also wait for the client to connect and run your tests reliably.

@eddyystop
Copy link
Author

These are not mocha tests, rather some test apps. I think this should at least be documented as its a time sink to track down.

@daffl
Copy link
Member

daffl commented Aug 1, 2017

I wonder if there is a good way for the generator to wait for the connection before starting the server.

@eddyystop
Copy link
Author

That is the conundrum.

One positive point is that MongoDB can only be used on the server. Can anything be done with async/await?

@daffl
Copy link
Member

daffl commented Sep 13, 2018

This issue was moved to feathersjs/feathers#996

@daffl daffl closed this as completed Sep 13, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants