Merge branch 'hotfix/online-err'
Showing
6 changed files
with
25 additions
and
8 deletions
@@ -40,6 +40,8 @@ app.locals.startTime = moment().format('YYYYMMDDHH'); | @@ -40,6 +40,8 @@ app.locals.startTime = moment().format('YYYYMMDDHH'); | ||
40 | // 全局注册library | 40 | // 全局注册library |
41 | yohoLib.global(config); | 41 | yohoLib.global(config); |
42 | 42 | ||
43 | +const logger = global.yoho.logger; | ||
44 | + | ||
43 | // zookeeper | 45 | // zookeeper |
44 | if (config.zookeeperServer) { | 46 | if (config.zookeeperServer) { |
45 | require('yoho-zookeeper')(config.zookeeperServer, 'wap', app.locals.wap = {}, global.yoho.cache); | 47 | require('yoho-zookeeper')(config.zookeeperServer, 'wap', app.locals.wap = {}, global.yoho.cache); |
@@ -52,6 +54,23 @@ app.set('etag', false); | @@ -52,6 +54,23 @@ app.set('etag', false); | ||
52 | 54 | ||
53 | app.enable('trust proxy'); | 55 | app.enable('trust proxy'); |
54 | 56 | ||
57 | +const safeStringify = require('fast-safe-stringify'); | ||
58 | + | ||
59 | +// 循环对象检测 | ||
60 | +app.set('json replacer', function(key, value) { | ||
61 | + if (!key) { | ||
62 | + let safeStr = safeStringify(value); | ||
63 | + | ||
64 | + if (/\[Circular\]/.test(safeStr)) { | ||
65 | + logger.error('stringify error:', value); | ||
66 | + } | ||
67 | + | ||
68 | + return JSON.parse(safeStr); | ||
69 | + } | ||
70 | + | ||
71 | + return value; | ||
72 | +}); | ||
73 | + | ||
55 | // 请求限制中间件 | 74 | // 请求限制中间件 |
56 | if (!app.locals.devEnv) { | 75 | if (!app.locals.devEnv) { |
57 | app.use(require('./doraemon/middleware/limiter')); | 76 | app.use(require('./doraemon/middleware/limiter')); |
@@ -60,8 +79,6 @@ if (!app.locals.devEnv) { | @@ -60,8 +79,6 @@ if (!app.locals.devEnv) { | ||
60 | // 指定libray目录 | 79 | // 指定libray目录 |
61 | global.utils = path.resolve('./utils'); | 80 | global.utils = path.resolve('./utils'); |
62 | 81 | ||
63 | -const logger = global.yoho.logger; | ||
64 | - | ||
65 | // 访问域名层级 | 82 | // 访问域名层级 |
66 | app.set('subdomain offset', 3); | 83 | app.set('subdomain offset', 3); |
67 | app.use(global.yoho.hbs({ | 84 | app.use(global.yoho.hbs({ |
@@ -103,7 +103,7 @@ const getResources = (params, options) => { | @@ -103,7 +103,7 @@ const getResources = (params, options) => { | ||
103 | let list = {}; | 103 | let list = {}; |
104 | let productSkns = []; | 104 | let productSkns = []; |
105 | 105 | ||
106 | - if (result.code !== 200) { | 106 | + if (result && result.code !== 200) { |
107 | return data; | 107 | return data; |
108 | } | 108 | } |
109 | 109 |
@@ -233,7 +233,7 @@ const order = (params) => { | @@ -233,7 +233,7 @@ const order = (params) => { | ||
233 | code: 200 | 233 | code: 200 |
234 | }).then(result => { | 234 | }).then(result => { |
235 | 235 | ||
236 | - if (result.data) { | 236 | + if (result && result.data) { |
237 | Object.assign(finalResult, {cancelReason: result.data}); | 237 | Object.assign(finalResult, {cancelReason: result.data}); |
238 | } | 238 | } |
239 | 239 |
@@ -74,8 +74,7 @@ exports.validate = (req, res, next) => { | @@ -74,8 +74,7 @@ exports.validate = (req, res, next) => { | ||
74 | captchaShow: true | 74 | captchaShow: true |
75 | }; | 75 | }; |
76 | 76 | ||
77 | - logger.info(`captcha validate result:${ | ||
78 | - captchaInput.toString() === captchaCode},user:${captchaInput};server:${captchaCode}`); | 77 | + logger.info(`captcha validate result:${(captchaInput && captchaInput.toString()) === captchaCode},user:${captchaInput};server:${captchaCode}`); // eslint-disable-line |
79 | 78 | ||
80 | _.set(req.session, 'captchaValidCount', errorCount - 1); | 79 | _.set(req.session, 'captchaValidCount', errorCount - 1); |
81 | 80 |
@@ -18,7 +18,7 @@ exports.page = (req, res, next) => { | @@ -18,7 +18,7 @@ exports.page = (req, res, next) => { | ||
18 | 18 | ||
19 | userApi.profile(req.user.uid) | 19 | userApi.profile(req.user.uid) |
20 | .then(userinfo => { | 20 | .then(userinfo => { |
21 | - userinfo = userinfo.data; | 21 | + userinfo = userinfo.data || {}; |
22 | 22 | ||
23 | res.render('chat/index', { | 23 | res.render('chat/index', { |
24 | module: 'service', | 24 | module: 'service', |
@@ -30,7 +30,7 @@ exports.page = (req, res, next) => { | @@ -30,7 +30,7 @@ exports.page = (req, res, next) => { | ||
30 | imSocket: global.yoho.config.domains.imSocket, | 30 | imSocket: global.yoho.config.domains.imSocket, |
31 | userData: { | 31 | userData: { |
32 | encrypteduid: crypto.encryption(null, uid + ''), | 32 | encrypteduid: crypto.encryption(null, uid + ''), |
33 | - avatar: helpers.image(userinfo.head_ico, 100, 100), | 33 | + avatar: userinfo.head_ico ? helpers.image(userinfo.head_ico, 100, 100) : '', |
34 | uname: userinfo.profile_name | 34 | uname: userinfo.profile_name |
35 | } | 35 | } |
36 | }); | 36 | }); |
@@ -32,6 +32,7 @@ | @@ -32,6 +32,7 @@ | ||
32 | "connect-multiparty": "^2.0.0", | 32 | "connect-multiparty": "^2.0.0", |
33 | "cookie-parser": "^1.4.3", | 33 | "cookie-parser": "^1.4.3", |
34 | "express": "^4.14.1", | 34 | "express": "^4.14.1", |
35 | + "fast-safe-stringify": "^1.1.13", | ||
35 | "feed": "^1.0.2", | 36 | "feed": "^1.0.2", |
36 | "geetest": "^4.1.1", | 37 | "geetest": "^4.1.1", |
37 | "lodash": "^4.17.4", | 38 | "lodash": "^4.17.4", |
-
Please register or login to post a comment