GeekyAnts / GeekyAnts/express-typescript
UnhandledPromiseRejectionWarning: MongoError: (Unauthorized) not authorized on admin to execute command
- Dominant language
- TypeScript
- Stars
- 1.3k
- Forks
- 321
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
The application throws a rejection which i believe has to do with the sessions package trying to make updates to mongodb on start. Full error log below
```
[WARN] UnhandledPromiseRejectionWarning: MongoError: (Unauthorized) not authorized on admin to execute command { insert: "system.indexes", documents: [[{ns admin.sessions} {key [{expires 1}]} {name expires_1} {expireAfterSeconds 0} {unique false}]], ordered: true }
at Function.MongoError.create (/Users/user/Documents/projects/express-typescript/node_modules/mongodb-core/lib/error.js:31:11)
at /Users/user/Documents/projects/express-typescript/node_modules/mongodb-core/lib/connection/pool.js:497:72
at authenticateStragglers (/Users/user/Documents/projects/express-typescript/node_modules/mongodb-core/lib/connection/pool.js:443:16)
at Connection.messageHandler (/Users/user/Documents/projects/express-typescript/node_modules/mongodb-core/lib/connection/pool.js:477:5)
at TLSSocket. (/Users/user/Documents/projects/express-typescript/node_modules/mongodb-core/lib/connection/connection.js:333:22)
at TLSSocket.emit (events.js:400:28)
at addChunk (internal/streams/readable.js:293:12)
at readableAddChunk (internal/streams/readable.js:267:9)
at TLSSocket.Readable.push (internal/streams/readable.js:206:10)
at TLSWrap.onStreamRead (internal/stream_base_commons.js:188:23)
at emitUnhandledRejectionWarning (internal/process/promises.js:168:15)
at processPromiseRejections (internal/process/promises.js:247:11)
at processTicksAndRejections (internal/process/task_queues.js:96:32)
```
**To Reproduce**
Steps to reproduce the behavior:
1. run ``` yarn dev ``` or ``` npm run dev ```
**Expected behavior**
App Should start
**Screenshots**
N/A
**Desktop (please complete the following information):**
- OS: iOS 12.5
**Smartphone (please complete the following information):**
N/A
**Additional context**
Cannot use this template with session
Contributor guide
Research direction
Start by running `yarn dev` or `npm run dev` and compare the startup failure with the MongoDB authorization error shown in the report. Trace the sessions package's startup database update and verify that the application starts without an unhandled rejection when the session configuration is corrected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- express, mongodb, typescript
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100