connect-session-knex
connect-session-knex copied to clipboard
Session store breaks when knex fails during its initialization
When creating new knex session store it performs some database queries (i.e. checks whether session table exists). If some of these queries fail, session store is unusable, because sessionStore.ready promise is rejected and therefore store is not able to perform any more queries.
IMHO there isn't much to do when this happens, but it would be nice if this behaviour is mentioned in README. My proposed fix is to add information about sessionStore.ready promise, which can be checked for rejected status if initialization failed.
const session = require('express-session');
const KnexSessionStore = require('connect-session-knex')(session);
const sessionStore = new KnexSessionStore({ knex });
sessionStore.ready.catch((err) => {
handleStoreError(err);
});
I'd accept a PR for this.