Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when deleting sessions #5

Open
adamsch1 opened this issue Dec 19, 2012 · 2 comments
Open

Error when deleting sessions #5

adamsch1 opened this issue Dec 19, 2012 · 2 comments

Comments

@adamsch1
Copy link

Howdy - Is this project still alive?

I noticed I was getting an error when connect-mysql-session tried to expire old sessions. I added a little extra logging and thought I would pass it along. Nothing obvious as t owhat is causing it.

/home/shane/slurp/node_modules/connect-mysql-session/lib/connect-mysql-session.js:61
sessions[i].destroy();
^
TypeError: Object function () {
return this.slice(-1)[0];
} has no method 'destroy'
at module.exports.get.Session.find.where.sid (/home/shane/slurp/node_modules/connect-mysql-session/lib/connect-mysql-session.js:61:41)
at EventEmitter.emit (events.js:126:20)
at Query.onSuccess (/home/shane/slurp/node_modules/connect-mysql-session/node_modules/sequelize/lib/sequelize/query.js:54:8)
at /home/shane/slurp/node_modules/connect-mysql-session/node_modules/sequelize/lib/sequelize/query.js:22:38
at Query.Client.query (/home/shane/slurp/node_modules/connect-mysql-session/node_modules/sequelize/node_modules/mysql/lib/client.js:108:11)
at Query.EventEmitter.emit (events.js:93:17)
at Query._handlePacket (/home/shane/slurp/node_modules/connect-mysql-session/node_modules/sequelize/node_modules/mysql/lib/query.js:51:14)
at Client._handlePacket (/home/shane/slurp/node_modules/connect-mysql-session/node_modules/sequelize/node_modules/mysql/lib/client.js:312:14)
at Parser.EventEmitter.emit (events.js:96:17)
at Parser.write.emitPacket (/home/shane/slurp/node_modules/connect-mysql-session/node_modules/sequelize/node_modules/mysql/lib/parser.js:71:14)

{ __definition:
{ options: { timestamps: true, hasPrimaryKeys: false },
name: 'Session',
tableName: 'Sessions',
attributes:
{ sid: 'VARCHAR(255) NOT NULL UNIQUE',
expires: 'INT',
json: 'TEXT',

@yss
Copy link

yss commented Jun 14, 2013

If you want to delete the current user session, you can use req.session.destroy();

@wonderwhy-er
Copy link

Hi, stumbled on this problem too.
I know what causing but not sure where exactly problem is.

Basically in my class Array class is extended with custom methods like this
Array.prototype.remove_duplicates = function(...

And apparently in this code remove_duplicates ends up in sessions array

                Session.findAll({where: ['expires < ?', Math.round(Date.now() / 1000)]})
                .on('success', function (sessions)
                {
                    if (sessions.length > 0)
                    {
                        console.log('Destroying ' + sessions.length + ' expired sessions.');
                        for (var i in sessions)
                        {
                            sessions[i].destroy();
                        }
                    }
                })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants