Skip to content

Commit f37c3c5

Browse files
Reflexclaude
andcommitted
docs(http2): clarify why httpAgent applies only to HTTP/1.1
Per review: no compatibility layer — just make the behavior and reasoning clear. A Node `http.Agent` configures HTTP/1.1 socket pooling, which has no equivalent in HTTP/2's multiplexed model (H2 knobs live on `H2FetchOptions`), so `httpAgent` has no effect on the H2 transport. Spell this out in the README HTTP/2 section and in the `resolveHttp2Fetch` doc. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 157044a commit f37c3c5

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ const runloop = new RunloopSDK({
377377
});
378378
```
379379

380-
The `httpAgent` option only applies to the HTTP/1.1 transport — the H2 pool manages its own connections. Passing an `httpAgent` without an explicit `http2` value keeps the client on HTTP/1.1 (with a one-time warning); pass `http2: false` to select HTTP/1.1 explicitly and silence the warning. A custom `fetch` always takes precedence over `http2`.
380+
The `httpAgent` option only applies to the HTTP/1.1 transport. A Node `http.Agent` configures HTTP/1.1 socket pooling (keep-alive, max sockets), which has no equivalent under HTTP/2 — the H2 transport multiplexes over its own managed connections — so `httpAgent` has no effect there. To tune HTTP/2 connection behavior, use `http2: { … }` instead. To keep an existing `httpAgent` working, passing one without an explicit `http2` value keeps the client on HTTP/1.1 (with a one-time warning); pass `http2: false` to select HTTP/1.1 explicitly and silence the warning. If both `httpAgent` and `http2` are set, `httpAgent` is ignored (also warned once). A custom `fetch` always takes precedence over `http2`.
381381

382382
## Semantic versioning
383383

src/lib/http2-transport.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ export interface Http2TransportOptions {
6464
* - `http2: H2FetchOptions` → a dedicated HTTP/2 pool tuned with those options.
6565
* - a bare `httpAgent` (no explicit `http2`) → HTTP/1.1, so existing agents keep
6666
* working; warns once since it overrides the HTTP/2 default.
67+
*
68+
* `httpAgent` never applies to the HTTP/2 path: a Node `http.Agent` configures
69+
* HTTP/1.1 socket pooling, which has no equivalent in HTTP/2's multiplexed model
70+
* (its knobs live on `H2FetchOptions`). So the H2 branches ignore it, warning
71+
* once, rather than pretending to honor it.
6772
*/
6873
export function resolveHttp2Fetch(options: Http2TransportOptions): Fetch | undefined {
6974
if (options.http2 === false) return undefined;

0 commit comments

Comments
 (0)