Skip to content

Deprecation warnings in unit tests related with MongoDB #161

@fgalan

Description

@fgalan

Unit test run is showing a log like this (just a fragment):

  Configuration cache
    When an IoT Agent sends a registration with configurations
(node:5571) UnhandledPromiseRejectionWarning: MongoError: topology was destroyed
    at /home/travis/build/telefonicaid/iotagent-manager/node_modules/mongodb/lib/db.js:918:78
    at handleCallback (/home/travis/build/telefonicaid/iotagent-manager/node_modules/mongodb/lib/utils.js:120:56)
    at /home/travis/build/telefonicaid/iotagent-manager/node_modules/mongodb/lib/db.js:316:5
    at /home/travis/build/telefonicaid/iotagent-manager/node_modules/mongodb/node_modules/mongodb-core/lib/connection/pool.js:469:18
    at _combinedTickCallback (internal/process/next_tick.js:132:7)
    at process._tickDomainCallback (internal/process/next_tick.js:219:9)
(node:5571) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:5571) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
      ✓ should store the configurations in MongoDB (104ms)
    When an IoT Agent updates the registration information with different configurations
(node:5571) UnhandledPromiseRejectionWarning: MongoError: topology was destroyed
    at /home/travis/build/telefonicaid/iotagent-manager/node_modules/mongodb/lib/db.js:918:78
    at handleCallback (/home/travis/build/telefonicaid/iotagent-manager/node_modules/mongodb/lib/utils.js:120:56)
    at /home/travis/build/telefonicaid/iotagent-manager/node_modules/mongodb/lib/db.js:316:5
    at /home/travis/build/telefonicaid/iotagent-manager/node_modules/mongodb/node_modules/mongodb-core/lib/connection/pool.js:469:18
    at _combinedTickCallback (internal/process/next_tick.js:132:7)
    at process._tickDomainCallback (internal/process/next_tick.js:219:9)
(node:5571) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:5571) UnhandledPromiseRejectionWarning: MongoError: topology was destroyed
    at /home/travis/build/telefonicaid/iotagent-manager/node_modules/mongodb/lib/db.js:918:78
    at handleCallback (/home/travis/build/telefonicaid/iotagent-manager/node_modules/mongodb/lib/utils.js:120:56)
    at /home/travis/build/telefonicaid/iotagent-manager/node_modules/mongodb/lib/db.js:316:5
    at /home/travis/build/telefonicaid/iotagent-manager/node_modules/mongodb/node_modules/mongodb-core/lib/connection/pool.js:469:18
    at _combinedTickCallback (internal/process/next_tick.js:132:7)
    at process._tickDomainCallback (internal/process/next_tick.js:219:9)
(node:5571) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
      ✓ should remove the older information (53ms)

Not sure about the cause of this problem... It may be related with some flaw in the DB connection logic.

The code should be reviewed and eventually fixed. Although the warning it at unit test it may hide some kind of bug with impact in real usage condition.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions