Conversation
1ce439f to
55e55b4
Compare
55e55b4 to
7070adb
Compare
metcoder95
approved these changes
Apr 20, 2025
Member
|
can we merge @tsctx? |
slagiewka
pushed a commit
to slagiewka/undici
that referenced
this pull request
Feb 14, 2026
productdevbook
added a commit
to productdevbook/misina
that referenced
this pull request
Apr 26, 2026
New optional driver under `misina/driver/undici`. Hands the entire
connection-pool / keep-alive / pipelining / HTTP/2 surface back to the
caller through any `undici.Agent` / `Pool` / `Client` they construct.
Solves the cross-region inference + RPC throughput problem the issue
flags: native fetch caps at 5 idle connections per origin, won't
negotiate H2, exposes no knobs.
```ts
import { Agent } from "undici"
import { undiciDriver } from "misina/driver/undici"
const api = createMisina({
driver: undiciDriver({
dispatcher: new Agent({
connections: 100,
keepAliveTimeout: 30_000,
allowH2: true,
}),
}),
})
```
Implementation:
- `undici` is declared in `peerDependencies` with
`peerDependenciesMeta.undici.optional: true`, so users who don't
use this driver pay nothing. Range: `^6 || ^7 || ^8`.
- `undici` is **dynamically imported** the first time `request()`
runs. The rest of misina keeps its static graph zero-dep.
- We re-issue the request as `fetch(url, { method, headers, body,
signal, redirect, dispatcher })` instead of passing the `Request`
instance directly — undici 8 stopped accepting cross-realm
`Request` objects (nodejs/undici#4170).
Bodies forward with `duplex: "half"` so streaming uploads work.
- `dispatcher` is typed as `any` on purpose — it's an opaque handle
from undici, and pinning it to a specific class would force every
consumer to align their undici major exactly. The driver doesn't
introspect it, just forwards it.
- `fetch` override option lets tests bypass the dynamic import.
Bundle: `driver/undici.mjs` capped at 1.5KB (currently ~700B). Lives
outside the existing 6KB `driver/` budget so the figure stays
honest.
Tests in test/driver-undici.test.ts spin up a local `node:http`
fixture and verify:
- Real undici Agent routes the request, returns a structurally-
compatible Response.
- A pool with `connections: 1` reuses sockets across three
concurrent requests (bounded socket count).
- Headers + method survive the round-trip (uses an `/echo-headers`
endpoint).
- The `fetch` override path is honored without touching `undici`.
`jsr.json` gets the matching `./driver/undici` export. README adds:
- A new highlight bullet.
- A "misina/driver/undici (Node-only, opt-in)" subsection under
Drivers with the high-throughput recipe + a note that the rest
of the package stays zero-dep.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Automated update of the WPT