call `unref`
tomfun opened this issue · comments
I used your library for a long time. But in the last week after updating node js and some dependencies my tests stuck. After some investigation I found out that you don't call unref
, your code:
SequelizeStore.prototype.startExpiringSessions = function startExpiringSessions () {
// Don't allow multiple intervals to run at once.
this.stopExpiringSessions()
if (this.options.checkExpirationInterval > 0) {
this._expirationInterval = setInterval(this.clearExpiredSessions.bind(this), this.options.checkExpirationInterval)
}
}
problem is solving by adding a line:
// ...
this._expirationInterval = setInterval(this.clearExpiredSessions.bind(this), this.options.checkExpirationInterval)
this._expirationInterval.unref() // < - -
// ...
Please fix it.
p.s. I just can't understand why I strike with the problem just now, what I have changed, why it did work fine in the past?..
Makes sense, thanks. Released Version 5.0.1 on NPM.
Hmm looks like this causes problems elsewhere. I testing an express app using jest and I after adding ConnectSessionSequelize my tests fail with the following error:
FAIL route-controllers\users.test.js
● Test suite failed to run
TypeError: this._expirationInterval.unref is not a function
40 |
41 | const SequelizeSessionStore = ConnectSessionSequelize(session.Store);
> 42 | const sessionStoreInstance = new SequelizeSessionStore({
43 | db: sequelize,
44 | });
45 |
at SequelizeStore.startExpiringSessions (node_modules/connect-session-sequelize/lib/connect-session-sequelize.js:163:32)
at new SequelizeStore (node_modules/connect-session-sequelize/lib/connect-session-sequelize.js:41:10)
at Object.<anonymous> (app.js:42:28)
at Object.<anonymous> (route-controllers/users.test.js:1:370)
// edit:
ok, just ignore me. I forgot to set testEnvironment: 'node'
in my jest config 😉