robinfehr / sessionstore

Sessionstore is a node.js module for multiple databases. It can be very useful if you work with express or connect.
MIT License
54 stars 22 forks source link

MongoDB - ReferenceError: debug is not defined #54

Closed rohantarai closed 4 years ago

rohantarai commented 4 years ago

my configuration for sessionstore:

app.use(
  session({
    genid: (req) => nanoid(36),
    secret: SESSION_SECRET,
    resave: false,
    saveUninitialized: false,
    store: sessionstore.createSessionStore({
      type: "mongodb",
      host: ["mcluster-shard-00-00-qp0ps.mongodb.net", "mcluster-shard-00-01-qp0ps.mongodb.net", "mcluster-shard-00-02-qp0ps.mongodb.net"],
      port: 27017,
      dbName: "auth-app",
      collectionName: "sessions",
      authSource: "admin",
      username: "<username>",
      password: "<password>",
      ignoreConcurrency: true,
      ttl: 60 * 60 * 24 * 14, // 14 days
    })
  })
);

And while running i get this error:

[nodemon] restarting due to changes...
[nodemon] starting `node ./index.js`
(node:2208) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
Mongodb connected
Server running at http://localhost:4000/graphql
D:\vscode-workspace\auth\server\node_modules\mongodb\lib\topologies\mongos.js:234
            throw err;
            ^

ReferenceError: debug is not defined
    at D:\vscode-workspace\auth\server\node_modules\sessionstore\lib\databases\mongodb.js:96:11
    at err (D:\vscode-workspace\auth\server\node_modules\mongodb\lib\operations\execute_operation.js:76:14)
    at executeCallback (D:\vscode-workspace\auth\server\node_modules\mongodb\lib\operations\execute_operation.js:67:25)
    at err (D:\vscode-workspace\auth\server\node_modules\mongodb\lib\operations\connect.js:192:23)
    at connectCallback (D:\vscode-workspace\auth\server\node_modules\mongodb\lib\operations\connect.js:343:5)
    at topology.connect.err (D:\vscode-workspace\auth\server\node_modules\mongodb\lib\operations\connect.js:471:14)
    at Mongos.<anonymous> (D:\vscode-workspace\auth\server\node_modules\mongodb\lib\topologies\mongos.js:231:11)
    at Object.onceWrapper (events.js:277:13)
    at Mongos.emit (events.js:189:13)
    at Timeout.<anonymous> (D:\vscode-workspace\auth\server\node_modules\mongodb\lib\core\topologies\mongos.js:739:14)
    at ontimeout (timers.js:436:11)
    at tryOnTimeout (timers.js:300:5)
    at listOnTimeout (timers.js:263:5)
    at Timer.processTimers (timers.js:223:10)
[nodemon] app crashed - waiting for file changes before starting...

Can you please check and provide me a resolution.

adrai commented 4 years ago

v1.3.6 should fix it

rohantarai commented 4 years ago

v1.3.6 should fix it

Thank you @adrai for the fix. Now i tried adding defaultOpt.useUnifiedTopology = true; to \node_modules\sessionstore\lib\databases\mongodb.js in order to remove the DeprecationWarning: pass option { useUnifiedTopology: true } to the MongoClient constructor. And it worked! The warning got removed. If you can update this change also then all seems to be good.

adrai commented 4 years ago

May you create a PR?

rohantarai commented 4 years ago

Done

adrai commented 4 years ago

thx

Faizan245 commented 1 year ago

v1.3.6 should fix it

i don't understand, what should i write in terminal