DimaCrafter / dc-api-core

Simple API core for your projects
MIT License
11 stars 5 forks source link

API server crash (caused by mongo) #17

Closed car1ot closed 4 years ago

car1ot commented 4 years ago

API server crashed with following error:

INFO  Starting API...
 INFO  Running startup script
 OK  Server started on port 8080 without SSL
 OK  Connected to database (mongo)
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(). The promise rejected with the reason:
MongoServerSelectionError: connection timed out
    at Timeout._onTimeout (C:\app\node_modules\mongodb\lib\core\sdam\topology.js:430:30)
    at listOnTimeout (internal/timers.js:531:17)
    at processTimers (internal/timers.js:475:7)

The reason of it was probably returning inside controller method:

    async getSomeDataForAuthorizedUser() {
        if (!this.session.user) return this.send('Forbidden', 403);
        const someData = await db.SomeData.find({ someKey: 'someValue' }).lean();
        this.send(someData);
    }
DimaCrafter commented 4 years ago

Error indicated that server can't connect to MongoDB, check your config. If this issue about fancy error repotring, it's dc-api-mongo issue and will be fixed soon.