klaemo opened a new issue, #379:
URL: https://github.com/apache/couchdb-nano/issues/379

   The `agentOptions` examples in `README.md` ("Pool size and open sockets") 
and `migration_guide_v10_to_v11.md` ("Agent options") end with:
   
   ```js
   const undici = require('undici')
   const undiciOptions = new undici.Agent(agentOptions)
   const nano = Nano({ url: 'http://127.0.0.1:5984', undiciOptions })
   ```
   
   Problems:
   
   1. Nano never reads an `undiciOptions` key (`lib/nano.js` only looks at 
`cfg.agentOptions`), so the agent is silently ignored and the default 
dispatcher is used.
   2. The README says to "supply an `agentOptions` object", but nano passes 
`agentOptions` straight to `fetch` as the `dispatcher`. A plain options object 
fails on every request with `error happened in your connection. Reason: 
TypeError: agent.dispatch is not a function`. Only a dispatcher instance (e.g. 
`new undici.Agent(...)`) works.
   3. Because nano uses Node's built-in `fetch`, the agent must come from an 
undici version that is compatible with the undici bundled into Node. For 
example, on Node 24 (bundled undici 7) an undici 8 `Agent` fails with 
`InvalidArgumentError: invalid onRequestStart method`, because undici 8 changed 
the dispatcher handler API (nodejs/undici#4786, #4827). The docs only say to 
add undici as a dependency, so `npm install undici` currently installs a 
version that breaks on Node 20–25.
   
   Reproduced with nano 11.0.7, CouchDB 3.3.3, Node 20.20.2, 22.23.4, 24.21.0, 
25.9.0 and 26.12.1. I'll open a docs PR that fixes the examples and recommends 
installing the undici major that matches `process.versions.undici`.
   
   This issue was prepared with Claude Code and reviewed by me before 
submission.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to