Skip to content
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

MySQL fields not returned #1113

Closed
brainsiq opened this issue Oct 9, 2020 · 3 comments · Fixed by #1116
Closed

MySQL fields not returned #1113

brainsiq opened this issue Oct 9, 2020 · 3 comments · Fixed by #1116
Labels
bug Something isn't working community integrations

Comments

@brainsiq
Copy link

brainsiq commented Oct 9, 2020

Describe the bug

The mysql module's query function has three parameters in the callback as shown by the example in the README

https://github.com/mysqljs/mysql#introduction

connection.query('SELECT 1 + 1 AS solution', function (error, results, fields) {
if (error) throw error;
console.log('The solution is: ', results[0].solution);
});

It appears that when using dd-trace-js that the final fields parameter is undefined.

Environment

  • Operation system: Docker image node:12.12.0-alpine
  • Node version: 12.12.0
  • Tracer version: 0.26.1
  • Agent version: 7.22.1
  • MySQL module version: 2.14.1
@brainsiq brainsiq added the bug Something isn't working label Oct 9, 2020
@brainsiq
Copy link
Author

brainsiq commented Oct 9, 2020

I believe the bug is here:

return tracer.scope().bind((err, res) => {
if (err) {
span.addTags({
'error.type': err.name,
'error.msg': err.message,
'error.stack': err.stack
})
}
span.finish()
done(err, res)
}, parent)

I assume this should have the same callback parameters as the mysql library. I have tried to use your tests to verify this but have not been able to get the tests to run - firstly seemed I had to use node 8, and even then have errors from node-gyp when building the couchbase module 🤷‍♂️

@brainsiq brainsiq changed the title Mysql fields not returned MySQL fields not returned Oct 9, 2020
@brainsiq
Copy link
Author

brainsiq commented Oct 13, 2020

In addition to this we can see an error in DataDog caused by our application code calling .forEach() on the undefined argument. The stack refers to the LOC referenced above (/usr/src/app/node_modules/dd-trace/packages/datadog-plugin-mysql/src/index.js:70:5):

TypeError: Cannot read property 'forEach' of undefined
at /usr/src/app/lib/mysqlHelpers/index.js:540:22
at bound (domain.js:420:14)
at runBound (domain.js:433:12)
at Query.<anonymous> (/usr/src/app/node_modules/dd-trace/packages/datadog-plugin-mysql/src/index.js:70:5)
at /usr/src/app/node_modules/dd-trace/packages/dd-trace/src/scope/base.js:54:19
at Scope._activate (/usr/src/app/node_modules/dd-trace/packages/dd-trace/src/scope/async_hooks.js:53:14)
at Scope.activate (/usr/src/app/node_modules/dd-trace/packages/dd-trace/src/scope/base.js:12:19)
at Query.bound [as _callback] (/usr/src/app/node_modules/dd-trace/packages/dd-trace/src/scope/base.js:53:20)
at Query.Sequence.end (/usr/src/app/node_modules/mysql/lib/protocol/sequences/Sequence.js:88:24)
at Query._handleFinalResultPacket (/usr/src/app/node_modules/mysql/lib/protocol/sequences/Query.js:139:8)
at Query.EofPacket (/usr/src/app/node_modules/mysql/lib/protocol/sequences/Query.js:123:8)
at Protocol._parsePacket (/usr/src/app/node_modules/mysql/lib/protocol/Protocol.js:279:23)
at Parser.write (/usr/src/app/node_modules/mysql/lib/protocol/Parser.js:76:12)
at Protocol.write (/usr/src/app/node_modules/mysql/lib/protocol/Protocol.js:39:16)
at Socket.<anonymous> (/usr/src/app/node_modules/mysql/lib/Connection.js:103:28)
at /usr/src/app/node_modules/dd-trace/packages/dd-trace/src/scope/base.js:54:19

@bengl
Copy link
Collaborator

bengl commented Oct 15, 2020

@brainsiq This is fixed by #1116, and should be in the next release (0.27.0).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working community integrations
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants