(node:12256) UnhandledPromiseRejectionWarning: Error: session store is unavailable
at Timeout.setTimeout [as _onTimeout] (\koa-generic-session\lib\session.js:441:16)
at ontimeout (timers.js:436:11)
(node:12256) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:12256) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
server error Error: session store is unavailable
at \koa-generic-session\lib\session.js:75:15
at Generator.next ()
at step (\koa-generic-session\lib\session.js:3:191)
at \koa-generic-session\lib\session.js:3:437
at new Promise ()
at \koa-generic-session\lib\session.js:3:99
at getSession (\koa-generic-session\lib\session.js:123:19)
at \koa-generic-session\lib\session.js:218:28
at Generator.next ()
at step (\koa-generic-session\lib\session.js:3:191)
at \koa-generic-session\lib\session.js:3:437
at new Promise ()
at \koa-generic-session\lib\session.js:3:99
at session (\koa-generic-session\lib\session.js:281:20)
at dispatch (\koa-compose\index.js:42:32)
at \koa-compose\index.js:34:12
at Application.handleRequest (\koa\lib\application.js:151:12)
at Server.handleRequest (\koa\lib\application.js:133:19)
at Server.emit (events.js:182:13)
at parserOnIncoming (_http_server.js:672:12)
at HTTPParser.parserOnHeadersComplete (_http_common.js:109:17) { request:
{ method: ‘GET’,
url: ‘/’,
header:
{ host: ‘localhost:3000’,
connection: ‘keep-alive’,
‘upgrade-insecure-requests’: ‘1’,
‘user-agent’:
‘Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36’,
accept:
‘text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8’,
‘accept-encoding’: ‘gzip, deflate, br’,
‘accept-language’: ‘zh-CN,zh;q=0.9,en;q=0.8’ } },
response: { status: 404, message: ‘Not Found’, header: {} },
app: { subdomainOffset: 2, proxy: false, env: ‘development’ },
originalUrl: ‘/’,
req: ‘’,
res: ‘’,
socket: ‘’ }
server error Error: session store is unavailable
at \koa-generic-session\lib\session.js:75:15
at Generator.next ()
at step (\koa-generic-session\lib\session.js:3:191)
at \koa-generic-session\lib\session.js:3:437
at new Promise ()
at \koa-generic-session\lib\session.js:3:99
at getSession (\koa-generic-session\lib\session.js:123:19)
at \koa-generic-session\lib\session.js:218:28
at Generator.next ()
at step (\koa-generic-session\lib\session.js:3:191)
at \koa-generic-session\lib\session.js:3:437
at new Promise ()
at \koa-generic-session\lib\session.js:3:99
at session (\koa-generic-session\lib\session.js:281:20)
at dispatch (\koa-compose\index.js:42:32)
at \koa-compose\index.js:34:12
at Application.handleRequest (\koa\lib\application.js:151:12)
错误分析: 未处理的Promise的错误
可能是async函数中 没有使用try/catch 块
或者 Promise 错误 没有catch()处理
具体错误的地方: session store is unavailable
1.查看koa-generic-session 具体API
reconnectTimeout: When store is disconnected, don’t throw store unavailable error immediately, wait reconnectTimeout to reconnect, default is 10s.
store unavailable 错误并不会立即就显示该错误 ,而是等待默认10s之后再次连接超时 才报该错误
推断: 连接超时错误 可能是redis未连接上 要么redis没有开启,要么连接redis需要用户名密码之类的
2.查看issues 在koa-generic-session
发现其中一个解决 提示需要重新启动redis server
解决: 重新启动redis server 即可
再次连接 发现正常
总结: 冷静分析,定位错误, 然后查找API和 issues 如果没有解决,再次去stackoverflow 解决。