dd-trace-js
                                
                                 dd-trace-js copied to clipboard
                                
                                    dd-trace-js copied to clipboard
                            
                            
                            
                        Distributed tracing not working after upgrade to NodeJS 18.9.0
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,
Seems to be due to experimental fetch API. Is that not officially supported by dd-trace yet?
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
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!
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?
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??
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.
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!
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. 😅
This doesn't appear to be fixed as I still have to include --no-experimental-fetch on version 4.16.0.