loopback-example-database icon indicating copy to clipboard operation
loopback-example-database copied to clipboard

Application simply crashed at starting up time if there is no connectivity from the app to database

Open dnguyenv opened this issue 9 years ago • 1 comments

When do npm start, if the connection between the host machine and database for some reason not available, the app simply crashed.

<mypath>/nodejs/strongloop/loopback-example-database/node_modules/loopback-connector-mongodb/node_modules/mongodb/lib/mongo_client.js:224
          throw err
          ^
MongoError: failed to connect to server [demo.strongloop.com:27017] on first connect
    at null.<anonymous> (<mypath>/strongloop/loopback-example-database/node_modules/loopback-connector-mongodb/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:326:35)
    at emitOne (events.js:77:13)
    at emit (events.js:169:7)
    at null.<anonymous> (<mypath>/strongloop/loopback-example-database/node_modules/loopback-connector-mongodb/node_modules/mongodb/node_modules/mongodb-core/lib/connection/pool.js:270:12)
    at g (events.js:260:16)
    at emitTwo (events.js:87:13)
    at emit (events.js:172:7)
    at Socket.<anonymous> (<mypath>/strongloop/loopback-example-database/node_modules/loopback-connector-mongodb/node_modules/mongodb/node_modules/mongodb-core/lib/connection/connection.js:175:49)
    at Socket.g (events.js:260:16)
    at emitOne (events.js:77:13)
    at Socket.emit (events.js:169:7)
    at connectErrorNT (net.js:996:8)
    at doNTCallback2 (node.js:441:9)
    at process._tickCallback (node.js:355:17)

npm ERR! Darwin 14.5.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v4.2.2
npm ERR! npm  v2.14.7
npm ERR! code ELIFECYCLE
npm ERR! [email protected] start: `node .`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] start script 'node .'.
npm ERR! This is most likely a problem with the loopback-example-database package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node .
npm ERR! You can get their info via:
npm ERR!     npm owner ls loopback-example-database
npm ERR! There is likely additional logging output above.

dnguyenv avatar Jan 27 '17 03:01 dnguyenv

This is expected behaviour. If you cannot reach your database, you'll want the explicit exception that provides information as to why.

kjdelisle avatar May 19 '17 19:05 kjdelisle