-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Context doesn't work with Node 4.3.1 #2094
Comments
If we change: Then we can retrieve the session without any problem:
Is there a problem in loopback, that this "get" method of context is loosing scope? |
Hi, it is being said that loopback.getCurrentContext() is pretty much deprecated at this point. This is working without any problems so far and I think others are using it as well in place of getCurrentContext(). So you could give it a try and see if you can make it work for your usecase, and avoid all the troubles that lie dormant within getCurrentContext() and the CLS. Just my 0.02$ 😉 |
What we are using is exactly what is written in the docs: But now i have redefined the part in server.js to:
But how now i can get the "ctx" inside of the remote method or other helper classes? |
@ekussberg This means that you also need to include this parameter in the remote method definition where you want to use it. You should end up having a signature like In the options argument you will receive the context that you injected. |
Hi @ekussberg @drywolf |
Hello, we have landed & released an official solution for injecting context via "options" arg, see #1495 and the related pull requests. There is also a parallel work done by @josieusa where loopback-context was upgraded to use cls-hooked under the hood. Feel free to try the new version I am closing this issue as it's no longer actionable for us. |
Hello,
we wanted to update our servers to Node v4.3.1 but unfortunately we have a problem with loopback context. We are using session manager for express and init the session when setContext is run:
Inside of this function the loopbackContext.get('session') works without problem. The problem is, that when we use the context in a remote method, it doesn't work, as loopbackContext.get('session') - undefined:
Any clues?
The text was updated successfully, but these errors were encountered: