Skip to content

undici's globalDispatcher missing methods when also importing node:http #59012

@vivedo

Description

@vivedo

Version

22.5 through 22.17

Platform

Darwin 24.5.0 Darwin Kernel Version 24.5.0

Subsystem

No response

What steps will reproduce the bug?

import 'node:http';
import undici from 'undici';

console.log(undici.getGlobalDispatcher().request) // undefined

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior? Why is that the expected behavior?

Undici's globalDispatcher (from its superclass Dispatcher) should have methods request, stream, pipeline, upgrade, connect

What do you see instead?

globalDispatcher Agent is lacking all of those methods

Additional information

  • external undici version does not affect the issue
  • starting from node 22.5.0, the http module requires internal undici 6.x: a1869fa
  • the issue does not occur when using undici 6.x without importing the http module
  • node 24.x, which does not exhibit the issue, uses undici 7.x internally
  • when http is imported, undici.getGlobalDispatcher() instanceof undici.Dispatcher returns false. I assume this happens because the default globalDispatcher resides in globalThis and is initialized by the built-in version of undici
import 'node:http';
import undici from 'undici';

console.log(undici.getGlobalDispatcher() instanceof undici.Dispatcher) // false

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions