Skip to content

Commit 3ea4243

Browse files
committed
chore(mysl2): fix last commit
1 parent 7f8500b commit 3ea4243

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/instrumentation/modules/mysql2.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,14 @@ module.exports = function (mysql2, agent, { version, enabled }) {
3131
// but is not in the public API so we need to extract it via prototype chain
3232
// ref: https://github.com/sidorares/node-mysql2/pull/3081
3333
const baseClass = Object.getPrototypeOf(mysql2.Connection);
34-
const hasQuery = typeof baseClass.prototype?.query === 'function';
35-
const hasExec = typeof baseClass.prototype?.exec === 'function';
34+
const baseProto = baseClass.prototype;
35+
const hasQuery = typeof baseProto?.query === 'function';
36+
const hasExec = typeof baseProto?.execute === 'function';
3637
const shouldPatchBase = hasQuery && hasExec;
3738

3839
if (shouldPatchBase) {
39-
shimmer.wrap(baseClass.prototype, 'query', wrapQuery);
40-
shimmer.wrap(baseClass.prototype, 'execute', wrapQuery);
40+
shimmer.wrap(baseProto, 'query', wrapQuery);
41+
shimmer.wrap(baseProto, 'execute', wrapQuery);
4142
} else {
4243
shimmer.wrap(mysql2.Connection.prototype, 'query', wrapQuery);
4344
shimmer.wrap(mysql2.Connection.prototype, 'execute', wrapQuery);

0 commit comments

Comments
 (0)