moleculerjs / moleculer-db

:battery: Database access service mixins for Moleculer
https://moleculer.services/
MIT License
152 stars 123 forks source link

Bug: mongodb adapter was not stopped when broker stop #24

Open zhaoyao91 opened 6 years ago

zhaoyao91 commented 6 years ago

When I stop the broker, the mongodb adapter was not stopped correctly, so although the test run successfully, it doesn't exit. I have to add the workaround code to my service:

  async stopped() {
    await this.adapter.client.close(true)
  }
icebob commented 6 years ago

This close is called, but the Promise is not returned:

https://github.com/moleculerjs/moleculer-db/blob/master/packages/moleculer-db-adapter-mongo/src/index.js#L81

I think it is the problem, right?

zhaoyao91 commented 6 years ago

yeah, this is one reason. there is some tricky point for mongo client.close, you should pass true to it to force close, otherwise it will hang there.