Skip to content

Commit

Permalink
bugfix: 如果当前环境已经有 domain 则未处理异常捕获中间件不会重复创建 domain
Browse files Browse the repository at this point in the history
主要是为了解决 AV.Cloud.CookieSession
写在未处理异常捕获中间件前面时,因为该中间件会重新创建 domain,会使
cookieSesion 无法找到正确的 domain 而导致状态不正确。
  • Loading branch information
sdjcw committed Nov 2, 2015
1 parent 2601fd3 commit b219639
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ app.use(cookieParser());

// 未处理异常捕获 middleware
app.use(function(req, res, next) {
var d = domain.create();
var d = null;
if (process.domain) {
d = process.domain;
} else {
d = domain.create();
}
d.add(req);
d.add(res);
d.on('error', function(err) {
Expand Down

0 comments on commit b219639

Please sign in to comment.