Error: RuntimeException: E_RUNTIME_ERROR: Session store is not initiated yet
Closed this issue · 4 comments
Join a team to work on a Project. After setting up and installing everything, I try to run the server but keep getting this error.
UnhandledPromiseRejectionWarning: RuntimeException: E_RUNTIME_ERROR: Session store is not initiated yet. Make sure that you have included the session middleware inside the list of global middleware.
And the session is already included global middleware.
I am using Nginx Proxy
OS
Ubuntu 18.04.1
Package version
"@adonisjs/session": "^1.0.28",
Node.js and npm version
Nodejs -- v10.14.2
npm -- 6.5.0
Hey @devamaz! 👋
It seems that one of your custom middleware is using the Session
provider before it was booted.
The issue seems to be in your ExtensionProvider.js
.
Could you please copy/paste the code of this Provider here?
Sure here
/**
* Childs of context can be access when a new instance is
* ready so we can set the currently logged-in user | null
*/
Context.onReady(function (ctx) {
if (ctx.view && typeof (ctx.view.share) === 'function') {
ctx.view.share({
user: (ctx.auth && typeof (ctx.auth.getUser) === 'function' ? ctx.auth.getUser() : null)
})
}
})
I was having the same issue, and it was just happening when an E_ROUTE_NOT_FOUND exception was thrown.
I made a workaround just by checking if the session is initiated before trying to use it
if (session.initiated)...
Solved. Thanks