From ff32186fe846c3b62dbd540bc44a98c6fc2b019f Mon Sep 17 00:00:00 2001 From: Shadowbeetle Date: Thu, 22 Dec 2016 11:58:23 +0100 Subject: [PATCH] fix(mongodb): fix cursor instrumentation below 2.0.0 --- lib/instrumentations/mongodb.js | 4 ++-- lib/instrumentations/mongodb.spec.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/instrumentations/mongodb.js b/lib/instrumentations/mongodb.js index 8d205db..aeadc16 100644 --- a/lib/instrumentations/mongodb.js +++ b/lib/instrumentations/mongodb.js @@ -54,12 +54,12 @@ function wrapper (mongodb, agent, pkg) { continuationMethod = typeof args[args.length - 1] === 'function' ? 'callback' : 'readStream' } else { // below 2.0.0 if a cursor description is provided, a cursor is returned, otherwise callback is called - continuationMethod = queryOptions.cursor ? 'readStream' : 'callback' + continuationMethod = queryOptions.cursor ? false : 'callback' } } else if (typeof args[args.length - 1] === 'function') { continuationMethod = 'callback' } else if (name === 'find') { - continuationMethod = 'readStream' + continuationMethod = version && semver.satisfies(version, '>= 2.0.0') ? 'readStream' : false } else if (version && semver.satisfies(version, '>= 2.0.0')) { continuationMethod = 'promise' } else { diff --git a/lib/instrumentations/mongodb.spec.js b/lib/instrumentations/mongodb.spec.js index dadfadf..f58005d 100644 --- a/lib/instrumentations/mongodb.spec.js +++ b/lib/instrumentations/mongodb.spec.js @@ -52,7 +52,7 @@ describe('The mongodb wrapper module', function () { method: 'find', protocol: 'mongodb', url: 'unknown', - continuationMethod: 'readStream' + continuationMethod: false }) })