question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Different behavior on Node.js 12.x and Node.js 14.x using knex 0.21.6

See original GitHub issue

Describe 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.

supported-technologies.

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:closed
  • Created 3 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
trentmcommented, Jan 5, 2021

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

0reactions
astormcommented, Jan 5, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Changelog | Knex.js
Various fixes to mssql dialect to make it compatible with other dialects #2653, Unique constraint now allow multiple null values, float type is...
Read more >
Problem with ESM modules · Issue #3978 · knex/knex - GitHub
When I log the value of config , it's undefined meaning something is broken with ESM via knex. This was working in 0.21.1....
Read more >
knex - npm
A SQL query builder that is flexible, portable, and fun to use! A batteries-included, multi-dialect (PostgreSQL, MySQL, CockroachDB, MSSQL, ...
Read more >
knex broken after upgrading from Node.js v12 to Node.js v16.4.0
I'm experiencing below error after upgrading to Node.js v16.4.0 (from Node.js v12). I'm using knex to connect to db (postgres) and using ORM...
Read more >
Bookshelf.js | Home
The Bookshelf library is initialized by passing an initialized Knex client instance. The Knex documentation ... Can I use standard node.js style callbacks?...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found