Skip to content

Commit 8d46af6

Browse files
committed
redis client quit bug
1 parent 082f7a9 commit 8d46af6

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

core/services/account-manager.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ proto.login = function (account, password) {
132132
throw new AppError.AppError(`您输入密码错误次数超过限制,帐户已经锁定`);
133133
}
134134
return users;
135-
});
135+
})
136+
.finally(() => client.quit());
136137
} else {
137138
return users;
138139
}
@@ -152,7 +153,8 @@ proto.login = function (account, password) {
152153
})
153154
.then(() => {
154155
return client.incrAsync(loginKey);
155-
});
156+
})
157+
.finally(() => client.quit());
156158
}
157159
throw new AppError.AppError("您输入的邮箱或密码有误");
158160
} else {
@@ -178,10 +180,12 @@ proto.sendRegisterCode = function (email) {
178180
.then(() => {
179181
//将token临时存储到redis
180182
var token = security.randToken(40);
181-
return factory.getRedisClient("default").setexAsync(`${REGISTER_CODE}${security.md5(email)}`, EXPIRED, token)
183+
var client = factory.getRedisClient("default");
184+
return client.setexAsync(`${REGISTER_CODE}${security.md5(email)}`, EXPIRED, token)
182185
.then(() => {
183186
return token;
184-
});
187+
})
188+
.finally(() => client.quit());
185189
})
186190
.then((token) => {
187191
//将token发送到用户邮箱
@@ -213,6 +217,7 @@ proto.checkRegisterCode = function (email, token) {
213217
}
214218
return ttl;
215219
})
220+
.finally(() => client.quit());
216221
throw new AppError.AppError(`您输入的验证码不正确,请重新输入`);
217222
}
218223
return storageToken;

core/services/client-manager.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ proto.clearUpdateCheckCache = function(deploymentKey, appVersion, label, package
3232
});
3333
}
3434
return null;
35-
});
35+
})
36+
.finally(() => client.quit());
3637
}
3738

3839
proto.updateCheckFromCache = function(deploymentKey, appVersion, label, packageHash) {
@@ -62,6 +63,7 @@ proto.updateCheckFromCache = function(deploymentKey, appVersion, label, packageH
6263
return rs;
6364
});
6465
})
66+
.finally(() => client.quit());
6567
}
6668

6769
proto.updateCheck = function(deploymentKey, appVersion, label, packageHash) {

test/api/users/users.test.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ describe('api/users/users.test.js', function() {
7878
.then(function (t) {
7979
storageToken = t;
8080
done();
81-
});
81+
})
82+
.finally(() => client.quit());
8283
});
8384

8485
it('should not check register code successful when email already exists', function(done) {
@@ -131,7 +132,8 @@ describe('api/users/users.test.js', function() {
131132
.then(function (t) {
132133
storageToken = t;
133134
done();
134-
});
135+
})
136+
.finally(() => client.quit());
135137
});
136138

137139
it('should not sign up successful when password length invalid', function(done) {

0 commit comments

Comments
 (0)