Skip to content

bug: debug logs duplicated #4615

@PandaWorker

Description

@PandaWorker

Bug Description

When launching debug mode, all events are written to logs 2-3 times.
Moreover, if you subscribe to the channel yourself, you will receive one event.

I understood that this is due to the fact that we subscribe to the event twice if we use undici, this is in undici inside the node and in undici as a dependency.

Reproducible By

NODE_DEBUG=undici node ./debug.js
import { request, Agent } from 'undici';

const dispatcher = new Agent({ connections: 1 });

async function execute() {
  const resp = await request('https://cdn.datatables.net/2.3.4/js/dataTables.min.js', { dispatcher });
  await resp.body.dump();
}

execute();
async function undici() {
  const { fetch} = await import('undici');
  const resp = await fetch('https://cdn.datatables.net/2.3.4/js/dataTables.min.js');
  await resp.arrayBuffer();
}

async function nodeUndici(){
  const resp = await fetch('https://cdn.datatables.net/2.3.4/js/dataTables.min.js');
  await resp.arrayBuffer();
}

// one debug logs
nodeUndici();

// duplicated debug logs
// undici();

Expected Behavior

Logs for a single query should not be duplicated.

Logs & Screenshots

Image

Environment

node - v24.9.0 and v22.19.0
undici - 7.16.0

Additional context

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