Skip to content

Undici instrumentation interferes with custom dispatchers #6439

@brkarcher

Description

@brkarcher

Tracer Version(s)

5.63.0

Node.js Version(s)

22

Bug Report

Expected Behavior

When I call:

const dispatcher = new undici.Agent({
  connect: { keepAlive: false }
});

const response = await undici.fetch(url, {
  dispatcher,
});

Undici should create the underlying net library connection with keepAlive: false.

Actual Behavior

The dispatcher info is lost and the underlying net connection is not sent any keepAlive values.

Specifications

  • Datadog Lambda Layer version: 84
  • Node version: 22
  • observed with dd-trace: 5.63.0.

Comments

NODE_DEBUG=net is useful here because it'll show us stuff like this:

NET 12: createConnection [
{
highWaterMark: 65536,
path: undefined,
localAddress: null,
port: '2773',
host: 'localhost'
},

keepAlive does show up there when specified.

My strong guess is that this is the code that's causing this bug. When we call in the style of undici.fetch(input: RequestInfo, init RequestInit) our input and info get repackaged into a globalThis.Request (being sent in here) which ends up dropping the dispatcher info.

This may be related to #6129 .

Reproduction Code

No response

Error Logs

No response

Tracer Config

No response

Operating System

No response

Bundling

Webpack

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions