You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Losing currentContext after installing Newrelic agent #1984
Customer.observe('access',functionlimitToOwner(ctx,next){varaccessToken=loopback.getCurrentContext().get('accessToken');console.log(accessToken);// display 'undefined' in the consolectx.query=_.merge({where: {ownerId: accessToken.userId}},ctx.query);next();});
Thanks @olivierl I reproduced your error.
I created a sandbox to simplify your example and test it with default db:
When I hit the endpoint GET/ customers I got
"error": {
"name": "TypeError",
"status": 500,
"message": "Cannot read property 'get' of null",
"stack": "TypeError: Cannot read property 'get' of null\n at limitToOwner (C:\\Users\\IBM_ADMIN\\Desktop\\triage3\\loopback-newrelic-issue\\common\\models\\customer.js:7:51)\n at notifySingleObserver (C:\\Users\\IBM_ADMIN\\Desktop\\triage3\\loopback-newrelic-issue\\node_modules\\loopback-datasource-juggler\\lib\\observer.js:98:22)\n at iterate (C:\\Users\\IBM_ADMIN\\Desktop\\triage3\\loopback-newrelic-issue\\node_modules\\loopback-datasource-juggler\\node_modules\\async\\lib\\async.js:181:13)\n at Object.async.eachSeries (C:\\Users\\IBM_ADMIN\\Desktop\\triage3\\loopback-newrelic-issue\\node_modules\\loopback-datasource-juggler\\node_modules\\async\\lib\\async.js:197:9)\n at doNotify (C:\\Users\\IBM_ADMIN\\Desktop\\triage3\\loopback-newrelic-issue\\node_modules\\loopback-datasource-juggler\\lib\\observer.js:95:11)\n at doNotify (C:\\Users\\IBM_ADMIN\\Desktop\\triage3\\loopback-newrelic-issue\\node_modules\\loopback-datasource-juggler\\lib\\observer.js:93:49)\n at doNotify (C:\\Users\\IBM_ADMIN\\Desktop\\triage3\\loopback-newrelic-issue\\node_modules\\loopback-datasource-juggler\\lib\\observer.js:93:49)\n at doNotify (C:\\Users\\IBM_ADMIN\\Desktop\\triage3\\loopback-newrelic-issue\\node_modules\\loopback-datasource-juggler\\lib\\observer.js:93:49)\n at Function.ObserverMixin._notifyBaseObservers (C:\\Users\\IBM_ADMIN\\Desktop\\triage3\\loopback-newrelic-issue\\node_modules\\loopback-datasource-juggler\\lib\\observer.js:116:5)\n at Function.ObserverMixin.notifyObserversOf (C:\\Users\\IBM_ADMIN\\Desktop\\triage3\\loopback-newrelic-issue\\node_modules\\loopback-datasource-juggler\\lib\\observer.js:91:8)"
}
We will look into the problem!
One more question, I am not so familiar with newrelic agent, have you tried to get currentContext without it?
Thank you @esopian@andressrg for reporting this, we will take a look. One more question for better debug: are you also getting this error with newrelic or even without using newrelic?
Hi, loopback-context is know to loose the context in many cases. We have deprecated it in favour of explicit context passing via the "options" argument, see #1495.
There is also an alternative approach being explored in https://github.com/strongloop/loopback-context, feel free to give it a try. If you do, then please report any issues found in loopback-context's issue tracker.
Activity
esopian commentedon Jan 29, 2016
+1
jannyHou commentedon Jan 29, 2016
hey @olivierl do you get the error from postgresql only or from the default db as well?
olivierl commentedon Jan 29, 2016
hi @jannyHou, I've made the test with the default db (memory) and it's worst,
loopback.getCurrentContext()returnsundefinedjannyHou commentedon Feb 2, 2016
Thanks @olivierl I reproduced your error.
I created a sandbox to simplify your example and test it with default db:
When I hit the endpoint
GET/ customersI gotWe will look into the problem!
One more question, I am not so familiar with
newrelic agent, have you tried to get currentContext without it?andressrg commentedon Feb 2, 2016
+1
jannyHou commentedon Feb 2, 2016
Thank you @esopian @andressrg for reporting this, we will take a look. One more question for better debug: are you also getting this error with newrelic or even without using newrelic?
barocsi commentedon Feb 4, 2016
could be same origin as #1807
jfurie commentedon Mar 8, 2016
+1
Valko54 commentedon Apr 27, 2016
+1
a-c-m commentedon Oct 5, 2016
+1
viczam commentedon Oct 5, 2016
-1
odlevakp commentedon Oct 5, 2016
+1
bajtos commentedon Jan 9, 2017
Hi, loopback-context is know to loose the context in many cases. We have deprecated it in favour of explicit context passing via the "options" argument, see #1495.
There is also an alternative approach being explored in https://github.com/strongloop/loopback-context, feel free to give it a try. If you do, then please report any issues found in loopback-context's issue tracker.
I am closing this issue.