-
Notifications
You must be signed in to change notification settings - Fork 400
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
Problem using with express #100
Comments
I'm sorry the agent is giving you trouble! New Relic for Node explicitly supports Express, and many people are using it successfully with Express, so let's see if we can figure out why it's not working for you:
If you can get us that information, I'm pretty sure we can get New Relic working for you. |
here is the asked detail.
i tried moving require('new relic'); to each thread for cluster.
5th. Sorry app.req is a typo i mean to say req.query |
Thanks for the details. Everything you've included looks fine to me. Just to be clear, before you were accessing |
I will post code soon |
+1 on this. I am seeing the same issue. req.query returns the function getQuery whenever I have newrelic enabled. |
After many hours of debugging, I think I found out why I was encountering this issue. I used Express.js as my web server, but the web server code also makes some calls out to external APIs. For those external calls, I was using restify as a JSON client. I would imagine that you guys likely tested Restify as a server, but for whatever reason, if restify is referenced anywhere within my web server code, it oddly turns req.query into the function getQuery. As soon as I comment out |
That is great, useful detective work! Thanks so much, Jeff! We actually don't have any tests combining Express and Restify, so the first step towards fixing this will be writing some. @ankitpatial, are you also using the Restify client in your application? |
No, i am not using Restify. I will soon try to debug my app to know the cause |
I pinpointed the problem, its some conflict with "manta" module that causing this problem. I have still not found the exact cause, but this what I can report for now. |
"manta" package is using restify inside it. Restify is causing issue because it overriding Request object methods. Any insight on it, why combining new relic with resitify breaks express? |
Great! It's good to know that it's the combination of Express and Restify that's causing the issue. Just so people watching this issue know, the Node team is currently heads down on feature development, and we'll get back to this issue after we've wrapped up our current chunk of feature work. Thanks for your patience! |
In case anyone else ever comes across this as I have, here is a potential work-around, you can use restify's getQuery function and then parse that with the querystring module.
|
I'm having the same problem. Any request that has query parameters is broken when I enable require newrelic. I use manta, express 3. |
I'll be looking into this more deeply shortly -- we're fixing a bunch of bugs right now, and enough people have run into this one that it merits more in-depth investigation. A test case that exhibits this problem would be very helpful for me in fixing this issue, if anyone feels like passing one along. |
I've created a repository with a set of test cases. Note that the bug does not appear if restify is required before newrelic. In the interim, would it be an acceptable stopgap to include restify before newrelic? The documentation insists that newrelic should be placed first. |
@Harrison-M if you require Restify before newrelic, much of the instrumentation won't be applied, and so at the very least you won't see any metrics for outbound HTTP requests. It could cause other problems with transaction tracing as well. I have some hope that Restify will get upgraded in such a way that it won't cause this problem anymore. Also maybe it doesn't happen with Express 4? New Relic is about to ship support for Express 4, and the Express dev team has claimed that the new version does less magic with the prototype. Thanks for the test cases! They're nice and tiny! |
@othiym23 You're quite welcome! Unfortunately, those test cases are using Express 4, and all of them succeed except index.js (the bug case). |
Dang! Shoulda checked the |
Any luck with this? For reference, here's my output from the test cases I posted above:
|
FWIW, I just tried this using |
I think I've tracked this down and am working on a fix. When creating a Restify server, various obtrusive things happen like extending IncomingMessage with a query() method. Unfortunately, Express also extends IncomingMessage with a query property. Some apps and modules use Restify only as a REST client. When an app also uses Express for serving and getting query params from IncomingMessages, our instrumentation causes the Restify query() method extension to override the Express query property. |
Great! @txase, i am glad you found the cause. I hope it will be fixed and released very soon? |
@ankitpatial We are still reviewing the fix, but I'm hopeful it will be released this week. |
This is great! Tried it on our apps and it's working well so far 👍 |
Fantastic news! Kudos to @txase for figuring out all out and fixing it. |
…/logs-in-context/app/semver-6.3.1 chore(deps): bump semver from 6.3.0 to 6.3.1 in /logs-in-context/app
…/json5-2.2.3 Bump json5 from 2.2.1 to 2.2.3
Remove tracer usage
docs: update slack invite link
I added new relic in one of my express app, but after adding package app started behaving abnormal.
Problem was with app.req object, instead of return a json object it started returning [Function: getQuery]
Any idea what can be wrong ?
I am now worried to use it in expressjs app, for now i dropped my idea to use it.
The text was updated successfully, but these errors were encountered: