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

src: more debug statements #708

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ function session(options) {
return function session(req, res, next) {
// self-awareness
if (req.session) {
debug('re-using existing session')
next()
return
}
Expand Down Expand Up @@ -302,13 +303,13 @@ function session(options) {

if (shouldDestroy(req)) {
// destroy session
debug('destroying');
debug('destroying session')
store.destroy(req.sessionID, function ondestroy(err) {
if (err) {
defer(next, err);
}

debug('destroyed');
debug('session destroyed')
writeend();
});

Expand Down Expand Up @@ -339,13 +340,13 @@ function session(options) {
return writetop();
} else if (storeImplementsTouch && shouldTouch(req)) {
// store implements touch method
debug('touching');
debug('touching session')
store.touch(req.sessionID, req.session, function ontouch(err) {
if (err) {
defer(next, err);
}

debug('touched');
debug('session touched')
writeend();
});

Expand All @@ -357,6 +358,7 @@ function session(options) {

// generate the session
function generate() {
debug('generating session')
store.generate(req);
originalId = req.sessionID;
originalHash = hash(req.session);
Expand Down Expand Up @@ -389,10 +391,17 @@ function session(options) {
})
}

function save() {
function save(callback) {
debug('saving %s', this.id);
savedHash = hash(this);
_save.apply(this, arguments);
_save.call(this, function (err) {
if (err) {
return callback(err)
}

debug('session saved')
callback.apply(this, arguments)
});
}

Object.defineProperty(sess, 'reload', {
Expand Down