KITFORMA · EDITORIAL GUIDE
Why does a Node HTTPS Agent not configure built-in fetch connections?
KitForma editorial guide. Built-in Node fetch uses Undici rather than the node:https Agent interface. An agent option copied from another HTTP client does not configure its connection dispatcher.
Step-by-step guidance
fetch(url, { dispatcher }). Keep an application-owned dispatcher reusable instead of constructing a connection manager for every request. If using setGlobalDispatcher, remember that it changes both built-in fetch and the installed Undici client; a library should not silently replace application-wide transport policy. Check process.versions.undici and the installed package compatibility before adopting version-specific options. Test that the intended dispatcher receives a controlled request, then separately verify proxy, TLS and pool behavior against an owned endpoint. Never disable certificate verification to make an incompatible agent appear to work.
Minimal example:
import assert from 'node:assert/strict';
const marker = new Error('controlled dispatcher failure');
let invoked = false;
const dispatcher = { dispatch() { invoked = true; throw marker; } };
await assert.rejects(
fetch('https://example.invalid/', { dispatcher }),
error => error.cause === marker
);
assert.equal(invoked, true);
// Tests dispatcher wiring only; no socket, proxy or TLS connection is opened.Sources and verification
Sources checked:
Scope: This editorial guide is based on the cited sources and tool behavior. A forum question or a query observed for our site does not establish market search volume, low competition, guaranteed rankings or inadequate answers elsewhere.
This starter guide was prepared by KitForma with AI assistance. It is not presented as a real member question or an independent user review. Check the sources and the result with your own file; report corrections in the discussion.