-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
fix(NODE-3358): Command monitoring objects hold internal state references #2858
fix(NODE-3358): Command monitoring objects hold internal state references #2858
Conversation
…leak internal state
…-internal-state-references
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some clean up on the test, otherwise LGTM
test/functional/apm.test.js
Outdated
expect(started[0].commandName).to.equal('insert'); | ||
expect(started[0].command.insert).to.equal('apm_test'); | ||
expect(succeeded).to.have.lengthOf(1); | ||
return client.close(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry for not catching this in the 4.0 PR, but, since this belongs in the clean up, the ideal way to do it would be to have this in an afterEach block with the creation of the client in a beforeEach; to avoid refactoring too much, it's fine to wrap this in its own describe for that purpose
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for the test clean up!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly LGTM 👍 just had a few minor stylistic requests.
lib/command_utils.js
Outdated
@@ -106,7 +108,7 @@ const extractCommand = command => { | |||
extractedCommand = result; | |||
} | |||
} else { | |||
extractedCommand = command.query || command; | |||
extractedCommand = command.query ? deepCopy(command.query) : deepCopy(command); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extractedCommand = command.query ? deepCopy(command.query) : deepCopy(command); | |
extractedCommand = deepCopy(command.query || command); |
I'd keep the more concise || syntax from the original code.
lib/utils.js
Outdated
@@ -871,6 +871,85 @@ function emitWarningOnce(message) { | |||
} | |||
} | |||
|
|||
// Copied from https://github.com/mongodb/node-mongodb-native/blob/70cace8343bead2f3c1a6d0cf07e20a8c4a9f45f/src/utils.ts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think these "copied from" comments are necessary.
test/functional/apm.test.js
Outdated
describe('Internal state references', function() { | ||
let client; | ||
|
||
beforeEach(function(done) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since newClient
is synchronous, you can just pass a function()
without a done
argument and omit the the done()
below.
test/functional/apm.test.js
Outdated
}); | ||
|
||
afterEach(function(done) { | ||
client.close(() => done()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
client.close(() => done()); | |
client.close(done); |
Modify extractCommand function used in apm event constructors to make deep copies of the command passed in
What changed?