dd-trace-js icon indicating copy to clipboard operation
dd-trace-js copied to clipboard

Distributed tracing not working after upgrade to NodeJS 18.9.0

Open Meemaw opened this issue 3 years ago • 2 comments

Expected behaviour Distributed tracing would work, connecting various services.

Actual behaviour We have upgraded our NodeJS 18.9.0 and noticed we lost distributed tracing.

Steps to reproduce

Environment

  • Operation system:
  • Node.js version: 18.9.0
  • Tracer version: 3.3.0
  • Agent version:
  • Relevant library versions: Next 12.2.5,

Meemaw avatar Sep 16 '22 07:09 Meemaw

Seems to be due to experimental fetch API. Is that not officially supported by dd-trace yet?

Meemaw avatar Sep 16 '22 10:09 Meemaw

No, I don't think so, even the undici (which is the root inspiration for node:fetch) isn't supported yet. https://github.com/DataDog/dd-trace-js/issues/1615

melkir avatar Sep 16 '22 11:09 melkir

We ran into this problem as well, and were able to work around the problem by launching nodev18 with --no-experimental-fetch (see: https://nodejs.org/en/blog/announcements/v18-release-announce/)

We're also not using fetch() directly, so ymmv...

Hope this helps!

khaong avatar Nov 23 '22 02:11 khaong

Hi, I was preparing to upgrade to dd-trace@3 when I discovered this issue. Am I understanding the above comments correctly that tracing is broken on node 18, even if fetch() is not used?

We ran into this problem as well [...] We're also not using fetch() directly, so ymmv...

That would block us from upgrading, keeping node on LTS is higher priority than the tracer. It also seems go against datadog's own guidance in the upgrade guide:

Node.js 12 has been EOL since April 2022 and is no longer supported. Generally speaking, we highly recommend always keeping Node.js up to date regardless of our support policy.

Can someone clarify under which circumstances this occurs? If this prevents the tracer from working with node LTS, should it be a considered a bug and prioritized?

kuritz avatar Dec 07 '22 18:12 kuritz

Wow, just spent a few days trying to figure out why we were not getting distributed logging in some of our apps.

Why on earth has datadog not acknowedged AND DOCUMENTED THIS??

madorb avatar Jul 25 '23 21:07 madorb

The global fetch API is supported in recent releases and should be fully working since 4.9.0/3.30.0/2.43.0. If you upgrade you can remove the --no-experimental-fetch flag and get proper visibility.

Apologies for the lack of response here. The issue got marked as a feature request as it was interpreted as a request to add fetch support so it wasn't being tracked in our bug triage and not prioritized as high. Apparently some polyfills like node-fetch started grabbing the global version though, if available, which broke some people. Seems like that's what happened to all you folks.

It's generally recommended if you have issues that need quick resolution to take it to your support contact rather than to open a Github issue as that will get much higher priority. The support channel has SLAs while github issues are best-effort. Github issues are mainly for non-critical issues and suggestions. Anything else should go to support as that will get broader attention and higher prioritization.

Qard avatar Aug 03 '23 06:08 Qard

Thanks so much @Qard appreciate you looking at it, it was definitely surprising behavior to find this not working, and that it wasn't as general an issue as it seemed at first!

madorb avatar Aug 08 '23 14:08 madorb

Yeah, hadn't really considered how node-fetch as a polyfill interacts when it switches to built-in fetch once it was available.

Recent versions should have full support for global fetch though so users of node-fetch or any other fetch polyfill should now still correctly get spans and distributed tracing linkage for that now. Hopefully that works for you. If you have any further issues ping me here and I should see it. 😅

Qard avatar Aug 09 '23 00:08 Qard

This doesn't appear to be fixed as I still have to include --no-experimental-fetch on version 4.16.0.

julesyoungberg avatar Oct 10 '23 16:10 julesyoungberg