-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Description
I noticed that when creating a new MongoDBStore new MongoDBStore({ ... }) the MongoDB connection gets established async and is not awaited. Following the example from the readme when server = app.listen(3000); is called, the MongoDB connection is probably not yet established and store.client is undefined.
In my opinion new MongoDBStore() should return a promise that can be awaited OR there should be a separate function for connecting:
const store = await new MongoDBStore({ ... });
OR:
const store = new MongoDBStore({ ... });
await store.connect();
Current workaround:
const store = new MongoDBStore({ ... });
await new Promise((resolve) => {
store.on('connected', () => {
resolve(undefined);
});
});
Metadata
Metadata
Assignees
Labels
No labels