Skip to content

mcollina/undici-7-8-global-dispatcher-repro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

undici 7/8 global dispatcher reproduction

This reproduction has only two runtime dependencies:

  • undici7 -> npm:undici@7.27.1
  • undici8 -> npm:undici@8.3.0

It starts a local HTTP server on 127.0.0.1 so the result does not depend on external networking.

Run

pnpm install
pnpm ok
pnpm ko

Expected:

  • pnpm ok succeeds because undici@8 fetch uses an undici@8 global dispatcher.
  • pnpm ko fails because undici@7 fetch picks up the process-global dispatcher installed by undici@8.

The failing shape is:

import * as undici7 from 'undici7'
import * as undici8 from 'undici8'

undici8.setGlobalDispatcher(new undici8.Agent())
await undici7.fetch('http://127.0.0.1:PORT/')

The failure is TypeError: fetch failed, caused by undici 8 rejecting the undici 7 request handler object:

InvalidArgumentError: invalid onRequestStart method
  at assertRequestHandler (.../undici@8.3.0/.../lib/core/util.js)
  ...
  at .../undici@7.27.1/.../lib/web/fetch/index.js

About

Reproduction for undici 7 fetch with undici 8 global dispatcher

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors