Different behavior on Node.js 12.x and Node.js 14.x using knex 0.21.6
See original GitHub issueDescribe the bug
Different behavior on Node.js 12.x and Node.js 14.x using knex 0.21.6
It is stated in your documentation that APM supports a minimal version of NodeJS 10.
Nevertheless, when using Node.js (v12.16.2) on our environment, we noticed that we had no more span returned for our SQL queries created via the knex driver (v0.21.6).
After some investigations, we decided to upgrade Node.js from v12.16.2 to 14.16.1 and the problem strangely disappeared.
We were indeed able to see the spans back.
We have tested serval combinations by activating debug mode:
Node.js v12.16.2 + knex (0.21.6) : no span sql
Node.js v14.15.1 + knex (0.21.6) : span sql
Expected behavior
Environment (please complete the following information)
- OS: Linux ubuntu 16.04 / macOS
- Node.js version: 12.16.2 / 14.15.1
- APM Server version: 7.9.3
- Agent version: 3.7.0
How are you starting the agent? (please tick one of the boxes)
- Calling
agent.start()
directly (e.g.require('elastic-apm-node').start(...)
) - Requiring
elastic-apm-node/start
from within the source code - Starting node with
-r elastic-apm-node/start
Additional context
-
Agent config options
Click to expand
serviceName: process.env.APM_SERVICE_NAME, containerId: containerId, secretToken: process.env.APM_SECRET_TOKEN, serverUrl: process.env.APM_SERVER_URL, active: true, captureSpanStackTraces: false, breakdownMetrics: false,
-
package.json
dependencies:Click to expand
"dependencies": { "elastic-apm-node": "3.7.0", "axios": "^0.20.0", "body-parser": "^1.19.0", "compression": "^1.7.4", "express": "^4.17.1", "helmet": "^4.1.1", "knex": "^0.21.1", "lodash": "^4.17.15", "moment": "^2.24.0", "mongoose": "^5.8.10", "mssql": "^6.2.0" }, "devDependencies": { "@types/compression": "^1.0.1", "@types/express": "^4.17.2", "@types/helmet": "0.0.48", "@types/lodash": "^4.14.161", "nodemon": "^2.0.2" } ``` </details>
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (6 by maintainers)
Top GitHub Comments
Some more background on that: This backport of the patch to v8 landed on node versions v14.6.0, v12.19.0, and v10.23.0. Here is the v8 CR discussion: https://chromium-review.googlesource.com/c/v8/v8/+/2215624 and a long technical dive of some of the issues (including mention if Knex’s “.then()” implementation) here: https://gist.github.com/Qard/faad53ba2368db54c95828365751d7bc
Thanks for the update @qfdk – it sounds like you’re all set here so we’re going to close this issue out. @rattkin – it wasn’t 100% clear if you had the same, or just a similar problem, so let us know if you’re still seeing problems.
Also – swiping some things @trentm shared with me, it looks like this cherry pick commit is what fixed things in more recent versions of node: https://github.com/nodejs/node/pull/33778 the (possibly inaccurate) TL;DR; on that is the
async_hooks
modules can now see when non-native promises/thenables run.