Skip to content

Commit c8f61a8

Browse files
committed
refactor: replace custom defer function with setImmediate
1 parent bbeca94 commit c8f61a8

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

index.js

+4-14
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,6 @@ var warning = 'Warning: connect.session() MemoryStore is not\n'
5656
+ 'designed for a production environment, as it will leak\n'
5757
+ 'memory, and will not scale past a single process.';
5858

59-
/**
60-
* Node.js 0.8+ async implementation.
61-
* @private
62-
*/
63-
64-
/* istanbul ignore next */
65-
var defer = typeof setImmediate === 'function'
66-
? setImmediate
67-
: function(fn){ process.nextTick(fn.bind.apply(fn, arguments)) }
68-
6959
/**
7060
* Setup session store with the given `options`.
7161
*
@@ -247,7 +237,7 @@ function session(options) {
247237
try {
248238
setcookie(res, name, req.sessionID, secrets[0], req.session.cookie.data)
249239
} catch (err) {
250-
defer(next, err)
240+
setImmediate(next, err)
251241
}
252242
});
253243

@@ -317,7 +307,7 @@ function session(options) {
317307
debug('destroying');
318308
store.destroy(req.sessionID, function ondestroy(err) {
319309
if (err) {
320-
defer(next, err);
310+
setImmediate(next, err);
321311
}
322312

323313
debug('destroyed');
@@ -342,7 +332,7 @@ function session(options) {
342332
if (shouldSave(req)) {
343333
req.session.save(function onsave(err) {
344334
if (err) {
345-
defer(next, err);
335+
setImmediate(next, err);
346336
}
347337

348338
writeend();
@@ -354,7 +344,7 @@ function session(options) {
354344
debug('touching');
355345
store.touch(req.sessionID, req.session, function ontouch(err) {
356346
if (err) {
357-
defer(next, err);
347+
setImmediate(next, err);
358348
}
359349

360350
debug('touched');

0 commit comments

Comments
 (0)