I’d love to hear if others are using New Relic with node-fibers (successfully or unsuccessfully), and/or if someone can explain how we might patch node-fibers to resolve these issues:
We believe we’re seeing memory leaks and conflated transactions because of our use of laverdet/node-fibers. Our hunch is the issue relates to newrelic’s use of node-continuation-local-storage, but thus far don’t understand the /why/. We were, however, able to construct a minimal test case that demonstrates our issue.
Take the following gist:
After an npm install (node v0.10.26, FWIW), run the provided test.sh script. Here’s my output:
$ sh test.sh express server listening at http://0.0.0.0:3000/ GET /one c24054cd939c GET /two c24054cd939c
You can see the two requests share the same transaction.
As I said, we’ve yet to understand why this happens, but we have found two workarounds so far that seem to fix the issue (read: give each request its own transaction):
Workaround 1: require express before newrelic
If we swap lines 3 and 4 in server.js, here’s what we see:
$ sh test.sh express server listening at http://0.0.0.0:3000/ GET /two 7da09ad31d08dc GET /one 1068e6dab0c3f10
Workaround 2: trade express.use for express.all '/*'
If we comment line 20 and uncomment line 21, we also see the correct behavior:
$ sh test.sh express server listening at http://0.0.0.0:3000/ GET /one 140709fe4382050 GET /two 1d8cf17561bf99
New Relic edit
- I want this, too
- I have more info to share (reply below)
- I have a solution for this
We take feature ideas seriously and our product managers review every one when plotting their roadmaps. However, there is no guarantee this feature will be implemented. This post ensures the idea is put on the table and discussed though. So please vote and share your extra details with our team.