quico
v0.10.2
Published
A pure JavaScript implementation of QUIC, HTTP/3, QPACK, and WebTransport for Node.js
Maintainers
Readme
The core transport is verified against six independent QUIC implementations (see Interoperability), but APIs may still change before v1.0. Please report issues!
Table of Contents
- What is QUIC / HTTP/3?
- Why QUICO?
- Requirements & Installation
- Quick Start
- Features
- Design Choices
- Interoperability
- API Reference
- Configuration & Tuning
- Debugging
- Testing
- Project Structure
- Security
- Known Limitations
- Roadmap
- Contributing
- Sponsors
- Contact
- License
⚡ What is QUIC / HTTP/3?
QUIC is the future of Internet transport protocols. Created at Google, standardized by the IETF as RFC 9000, QUIC powers HTTP/3 and is already deployed at scale by the world's largest platforms. It was specifically designed to overcome the limitations of TCP and deliver a faster, smoother, and more resilient web.
Key advantages of QUIC include:
Eliminating bottlenecks — With TCP, data must arrive strictly in order. If a single packet is lost or delayed, all subsequent packets are blocked until it arrives — a phenomenon called head-of-line blocking. QUIC removes this bottleneck by running over UDP and multiplexing independent streams: each stream makes progress on its own, and a loss on one never stalls the others.
UDP efficiency — By running over UDP, QUIC bypasses decades of kernel-level TCP constraints, enabling fast connection handling even on constrained devices such as smartphones, IoT hardware, or edge gateways.
Security by default — TLS 1.3 is built directly into the protocol. Every connection is encrypted — no exceptions, no downgrade paths. Even the packet headers are cryptographically protected.
Seamless mobility — Connections are identified by connection IDs rather than IP/port 4-tuples, so a session can survive a device moving across networks (Wi-Fi → 4G/5G) or changing addresses.
Lower latency — QUIC merges the transport and TLS handshakes into a single exchange, significantly reducing connection setup time.
Smarter congestion control — Modern algorithms such as BBR continuously measure bandwidth and round-trip time instead of only reacting to loss, adapting to real-world network conditions in real time.
QUIC combines UDP speed, TCP reliability, mandatory TLS security, and adaptive multiplexing into one transport layer.
HTTP/3 (RFC 9114) is the layer on top: the evolution of the web's application protocol. Instead of riding over TCP, HTTP/3 maps requests and responses directly onto QUIC streams, with QPACK header compression designed to avoid reintroducing head-of-line blocking. The result: faster page loads and real-time applications that scale across the modern web.
🧠 Why QUICO?
Node.js is the backbone of countless modern web applications — yet it has no native QUIC implementation. The browser you're reading this in speaks HTTP/3. The CDN that served this page speaks HTTP/3. Your Node server? Stuck on TCP.
Why? Supporting QUIC inside Node.js requires deep access to TLS internals that
Node's existing TLS APIs simply don't expose. TLS-over-TCP hands you an encrypted
byte stream; QUIC needs something entirely different — the raw handshake secrets
at each encryption level, so it can derive its own packet-protection keys and encrypt
each packet individually. node:tls was never built to hand those out. Beyond the
crypto, QUIC demands a genuinely complex architecture: interlocking state machines
across three packet-number spaces, a packet scheduler with pacing, loss detection
timers, and congestion control.
QUICO brings this missing capability directly into the Node.js ecosystem. It is a from-scratch JavaScript implementation of QUIC, HTTP/3 and WebTransport, built without OpenSSL and without a single line of native code. The cryptographic layer is LemonTLS — a pure JavaScript TLS 1.3 library built by the same author specifically to expose what QUIC needs. Together, QUICO and LemonTLS form a complete, fully auditable JavaScript networking stack from the UDP socket all the way up to HTTP/3.
No build tools. No platform-specific binaries. No node-gyp. It runs anywhere Node runs
— Linux, macOS, Windows, ARM, Docker, edge — and when something breaks at 3 AM, the
stack trace ends in code you can open, not in a .node binary.
📋 Requirements & Installation
| Requirement | Notes |
|---|---|
| Node.js 18+ | ESM only (import). Tested on 18, 20 and 22. |
| No compiler | Pure JavaScript — no native addons. |
| Dependencies | lemon-tls (TLS 1.3), flat-ranges (range arithmetic), and cryptographic-formats (certificate formats — the dates WebTransport's serverCertificateHashes checks; lemon-tls reads certificates with it too). Nothing else. |
npm install quicoQUICO is an ES module. Use import, and make sure your package.json has
"type": "module" (or use the .mjs extension).
📦 Quick Start
Server
import quico from 'quico';
import fs from 'node:fs';
const server = quico.createServer({
key: fs.readFileSync('server.key'),
cert: fs.readFileSync('server.crt')
}, (req, res) => {
res.writeHead(200, { 'content-type': 'text/plain' });
res.end('Hello from HTTP/3!');
});
server.listen(4433, () => {
console.log('HTTP/3 server on https://localhost:4433');
});Client
import quico from 'quico';
quico.request('https://www.google.com/', (res) => {
console.log('Status:', res.statusCode); // 200
console.log('Protocol:', res.httpVersion); // "3.0"
res.on('data', (chunk) => process.stdout.write(chunk));
}).end();GET and HEAD requests are ended for you on the next tick. For any method with a body, call
.end()— likenode:https, the request isn't sent until you do.
📂 More examples in
examples/
✨ Features
One HTTP stack, three versions
QUICO does not import node:http, node:https, node:http2 or node:tls. HTTP/1.1,
HTTP/2 and HTTP/3 are all implemented here, and all three hand the application the
same IncomingMessage / ServerResponse — so a framework written against node:http
runs over any of them without knowing which. For the network and cryptography, all
QUICO takes from Node is node:net (TCP) and node:dgram (UDP); the cryptography is
cryptographic-primitives's and the certificate formats cryptographic-formats's.
- HTTP/3 (RFC 9114) with QPACK, static and dynamic tables (RFC 9204); up to 100
blocked streams — a field section that references an entry whose insertion has not
arrived yet waits for it (
SETTINGS_QPACK_BLOCKED_STREAMS) - HTTP/2 (RFC 9113) with HPACK, including h2c by connection preface
- HTTP/1.1 with keep-alive, chunked transfer and trailers
- One server listens on UDP and TCP and serves all three;
Alt-Svcis advertised on HTTPS HTTP/1.1 and HTTP/2 responses so browsers discover HTTP/3 (seealtSvc) - Client with automatic H3 → H2 → H1.1 fallback, connection pooling and per-origin coalescing
103 Early Hints(res.writeEarlyHints()) on all three versions- Extra protocols on the same TCP port through ALPN or byte sniffing
(
server.addProtocol())
QUIC Transport
- QUIC v1 (RFC 9000) and QUIC v2 (RFC 9369) — Initial, Handshake and 1-RTT packet
spaces; everything a version decides (salt, key labels, packet type bits, Retry key)
in one profile per version (
quic_version.js), the rest shared - Compatible version negotiation (RFC 9368): a client that starts in v1 and offers v2 is
moved to v2 without a round trip when the server prefers it (
quicVersions); Version Negotiation and a second attempt when there is no compatible version - TLS 1.3 handshake via LemonTLS, no OpenSSL (RFC 9001)
- Version Negotiation (RFC 9000 §6)
- HelloRetryRequest — X25519, P-256, P-384
- AES-128-GCM and AES-256-GCM
- Key Update — bidirectional key phase rotation (RFC 9001 §6)
- Session resumption on the server, with ticket keys shared across connections
(
ticketKeys) - Retry and address validation, switchable at runtime (
validateAddress) - Handshakes under way counted for the application (
getPendingHandshakes(),'handshakeLoad'), and capped per client address (maxHandshakesPerAddress) - Anti-amplification limit — 3× until the client's address is validated (RFC 9000 §8.1)
- Connection migration (RFC 9000 §9): a client may move to another network (Wi-Fi to cellular) and go on in the same connection — each side issues spare connection IDs (NEW_CONNECTION_ID, RETIRE_CONNECTION_ID, Retire Prior To) and the new path is addressed by one of its own (§9.5); NAT rebinding is followed too. Each new address is validated with PATH_CHALLENGE first, and congestion/RTT state starts over on a new IP
- NEW_TOKEN (RFC 9000 §8.1.3): a returning client's address needs no proof — no Retry, no 3× limit; the agent keeps one token per server and uses it once
- ACK frequency (draft-ietf-quic-ack-frequency): a receiver follows ACK_FREQUENCY and IMMEDIATE_ACK; a sender with many packets in flight asks for an ACK every ~10 packets — an 8 MB download, ~340 ACK packets instead of ~3,400
grease_quic_bit(RFC 9287): the fixed bit sent unpredictable to a peer that allows it (not on a UDP port shared with other protocols)- Certificate compression (RFC 8879, in LemonTLS): the server's chain compressed for a
client that offers it (Chrome: brotli), only when it comes out smaller, and once per chain
(cached). The client offers brotli, zstd and zlib on every version. A client certificate
goes compressed when the server's CertificateRequest asks. Decompressing stops at the
declared length and never goes past 128 KB. With an RSA-4096 chain, the server's
Handshake flight over QUIC went from 9.6 KB to 6.0 KB. The server's algorithms are
createServer({ certificateCompression }); what went on the wire, each way, issocket.getNegotiationResult().certificateCompressionon every version. The chain is compressed when the server is made, in the background, not by the first client's handshake (brotli at quality 11: ~4 ms for a small chain, ~18 ms for 9 KB) - Encrypted Client Hello (RFC 9849, in LemonTLS) — HTTP/3, HTTP/2 and HTTP/1.1 alike: the
site name and ALPN travel encrypted, to a key published in DNS (
ech; see Encrypted Client Hello) - Stateless reset with HMAC-derived tokens (
resetTokenSecret) - Stream and connection-level flow control with sliding windows
- Stream limits enforced in both directions, and raised with
MAX_STREAMSas streams close (RFC 9000 §4.6) - Loss detection with PTO and exponential backoff (RFC 9002)
- BBR-style congestion control with pacing
- Path MTU discovery (DPLPMTUD, RFC 8899)
- Unreliable datagrams (RFC 9221)
- Idle timeout, keep-alive, TLS keylog export for Wireshark
WebTransport
- Client and server (RFC 9297 + draft-ietf-webtrans-http3)
- Bidirectional and unidirectional streams (Node.js Duplex API)
- Unreliable datagrams
- Natural API:
req.on('stream'),res.sendDatagram(),res.writeHead(200)to accept - Over HTTP/3 only: a session asked for over HTTP/1.1 or HTTP/2 is answered
501, with no body, before the application sees it
WebSocket
- Server over all three versions: HTTP/1.1 Upgrade, HTTP/2 extended CONNECT
(RFC 8441) and HTTP/3 extended CONNECT (RFC 9220) — one
'upgrade'event for all WebSocketServerin the shape of thewspackage, and the browser'sWebSocketclient (HTTP/1.1), checked against the WPTwebsockets/testsWebSocketStream(experimental): the streams version, with backpressure both ways
CONNECT-UDP
- A UDP proxy (RFC 9298, MASQUE) over HTTP/3 — QUIC datagrams — and HTTP/2 and
HTTP/1.1 — capsules:
server.on('connectUdp', (req, tunnel) => tunnel.accept()) - Its client:
quico.connectUdp(proxy, { host, port }), adgram.Socketthat goes through the proxy
Fingerprinting
- JA4H (HTTP request), HTTP/2 and HTTP/3 protocol fingerprints, per request
- TLS fingerprints (JA4, JA4S, JA5) through LemonTLS
profileRequest()— scores how well a request's protocol behaviour matches the client it claims to be
🧬 Design Choices
Two QUIC implementations can both be fully conformant and still behave completely differently on the wire. RFC 9000 defines what must happen; it deliberately leaves how to the implementer. This section documents where QUICO made a choice — the places where another implementation would reasonably do something else.
The send model: range reconciliation, not retransmission
This is the foundational choice, and the one that most distinguishes QUICO from other implementations.
How it's normally done. RFC 9002 describes tracking each packet you send along with the frames it contained. When loss detection fires, you look up that packet, recover its frames, and put them back in a retransmission queue. The sender is procedural: an event happens (loss), and you perform a corrective action (re-enqueue). Almost every QUIC stack works this way.
What QUICO does instead. There is no sent_packets table, no stored frame copies,
and no retransmission queue — those concepts don't exist in the codebase. Each stream
keeps only this:
{
q: [Uint8Array, …], // the bytes the application wrote, as written
acked_ranges: [from, to, …], // byte ranges the peer has confirmed
in_flight_ranges: { 47: [from, to], 48: [from, to] }, // packet number → bytes it carries
missing_ranges: [from, to, …] // the answer to the question below, kept (see below)
}Every send opportunity asks one question, and it's a set operation:
missing = invert(acked_ranges ∪ in_flight_ranges, 0, total_size)Whatever's missing goes out. That's the whole algorithm. The sender doesn't remember what it did — it asks what the peer still needs, every time. It's a declarative model: continuously reconcile "what the peer has" against "what the peer should have", and emit the difference.
The answer is kept, not recomputed. acked_ranges ∪ in_flight_ranges was computed
from every packet in flight, three or four times per send pass — with thousands of
packets in flight on a large transfer, that was a fifth of the CPU. Each stream now holds
the answer itself, as flat-ranges' three
states of what the peer has:
| flat-ranges | QUICO | the peer… |
|---|---|---|
| have | acked_ranges | has these bytes — acknowledged |
| not_have | missing_ranges | surely lacks them — never sent, or given up on |
| unknown | in_flight_ranges (by packet) | may have them — in flight |
have and not_have never overlap, and missing_ranges is what the sender sends from.
It changes at exactly five points (nothingMissing
documents them):
| Event | missing_ranges |
|---|---|
| the application writes bytes | added |
| bytes yielded into a packet (get_stream_chunks) | removed |
| an ACK credits bytes — a late one included | removed |
| the expiry timer gives a packet up | its bytes added, except any acknowledged meanwhile (add_not_have) |
| a packet that never left (encryption failed) | its bytes added |
Adding a packet's bytes back is exact because each byte is in flight in one packet at
most: bytes are yielded only while missing, and become missing again only when the
packet that carried them expires. sendstate_test checks missing_ranges against the
complement of acked_ranges ∪ in_flight_ranges, rebuilt from scratch every few
milliseconds under loss, reordering and late ACKs, and that it never overlaps
acked_ranges.
Congestion control counts something else: packets, by their size on the wire — header,
frames, padding and AEAD tag, whatever they carry, as RFC 9002 counts bytes in flight.
Each packet the peer must acknowledge enters pkt_in_flight when it leaves and goes when
it is acknowledged or given up on; app_bytes_in_flight is their sum, kept as they come
and go, and an ACK delivers what its packets weighed. The window, the pacing rate and the
bandwidth BBR measures are one unit. (They used to be STREAM bytes, which left out the
packets' overhead, packets of control frames, and most of the handshake.)
Loss detection, therefore, is still one step:
delete st.in_flight_ranges[pn]; // not in flight any more
flat_ranges.add_not_have(acked, missing, lostRanges); // → missing again, unless ackedDeleting the mapping is the entire recovery action. Nothing is queued, scheduled, or
flagged. The bytes simply reappear in the next missing computation and get sent
along with everything else.
The consequence: a packet is a disposable container, not an identity. The data that was in lost packet #47 doesn't come back as packet #47's contents. It comes back as bytes that need sending, and the next burst may:
- re-slice them differently — the chunk boundaries depend on that burst's byte budget, so a lost 1200-byte range might go out as 400 bytes appended to one packet and 800 in the next;
- coalesce them with new data from the same stream, in a single STREAM frame;
- pack them alongside other streams' data in the same packet, via the round-robin scheduler below.
Packet numbers and stream byte-offsets are fully decoupled: PNs are transient bookkeeping for the loss timer, while the byte range is the only durable identity of data. This is possible because QUIC frames carry explicit offsets — the receiver reassembles by offset and genuinely does not care how the bytes were packetized.
Why this design:
- State can't drift. A retransmission queue is mutable state maintained incrementally, and every incremental structure can desynchronize from reality — entries duplicated, entries dropped, a range acked while a stale copy still sits in the queue. Range arithmetic derives the truth fresh each pass, so a byte range can neither be forgotten nor sent twice by bookkeeping error.
- Recovery is free. No priority juggling between "retransmit queue" and "new data queue"; repairs and new data are the same thing, drawn from one computation and paced by the same congestion controller.
- Late information is harmless. An ACK arriving after the loss timer already fired
isn't a contradiction to reconcile — it just adds a range to
acked_ranges, and the next pass naturally stops sending those bytes.
What it costs. A send opportunity reads a stream's few missing_ranges — usually
one or two — and keeping them is a range insert or removal per write, and per packet
sent, acknowledged or expired. The expiry walk visits a
stream's packets oldest first and stops at the first one still within the timeout, so
it costs the packets that expired, not every packet in flight.
The receive side is symmetric. Incoming data is recorded in a ranges array, and
delivery walks the contiguous prefix. Same range algebra, mirrored — which is exactly
why the receiver must tolerate chunks whose boundaries don't line up with anything it
saw before: on the sending side, they never had to. It does so at insertion: only the
bytes not already held are stored, so stored pieces never overlap, tile ranges
exactly, and delivery is an exact-key walk. A peer cannot make reassembly expensive
either — the number of gaps per stream is capped (1000, as in quic-go), and pieces are
compacted into one buffer per contiguous run when they outnumber the gaps.
Congestion control: BBR-style, not loss-based
The choice: most QUIC stacks ship a loss-based controller — quic-go uses Reno with HyStart++, others default to CUBIC. QUICO implements a model-based controller in the BBRv1 family instead.
The difference is philosophical. Loss-based algorithms grow the window until packets drop, which means they require queue overflow to find the limit — and they misread random wireless loss as congestion. BBR builds an explicit model of the path and steers by it:
BDP = BtlBw × RTprop- BtlBw (bottleneck bandwidth) — a windowed maximum of per-round delivery rate over the last 10 rounds. Sampling happens once per round-trip, not per ACK: under ACK aggregation, per-ACK samples spike and a windowed-max latches onto the spike.
- RTprop (round-trip propagation) — a windowed minimum of RTT over 10 seconds, so queue-induced inflation decays out of the model.
Three states drive the two output knobs:
| State | Pacing gain | Purpose |
|---|---|---|
| startup | 2.89 (≈ 2/ln 2) | Exponential ramp to discover BtlBw. Exits after 3 rounds without ≥25% growth — the pipe is full. |
| drain | 1/2.89 | One phase to drain the queue startup necessarily built. |
| probe_bw | [1.25, 0.75, 1, 1, 1, 1, 1, 1] | Steady state: probe for more bandwidth, then yield to drain what the probe queued. |
The pacing rate (gain × BtlBw) spreads packets smoothly rather than dumping
window-sized bursts into the bottleneck; the congestion window (cwnd_gain × BDP)
is the in-flight backstop. Both are clamped to floors and ceilings so a single bad
measurement can never wedge the connection.
Watch it live, one line per round-trip:
QUICO_DEBUG_BBR=1 node yourserver.js[bbr] round=5 startup BtlBw=8.96Mbps RTprop=16ms BDP=17920B → cwnd=51789B pace=25.89Mbps
[bbr] round=9 drain BtlBw=10.98Mbps RTprop=16ms BDP=21952B → cwnd=63441B pace=3.80Mbps
[bbr] round=15 probe_bw BtlBw=10.98Mbps RTprop=16ms BDP=21952B → cwnd=27440B pace=10.98MbpsThat trace is a real run through a 10 Mbps bottleneck with a 25-packet queue: startup finds the link in ~7 rounds, drain empties the queue, probe_bw settles within 5% of line rate.
The first round trips
A page's first view is decided before any of this has measured anything: by the window
the connection starts with, and how fast it grows. QUICO starts at 20 packets (24 KB)
— initialCongestionWindow — where RFC 9002 suggests 10. That is where TCP effectively
is when its response goes out: a 10-segment TCP window has grown on the acknowledged
handshake segments by then, and a QUIC connection at 10 left a 60 KB page a round trip
behind HTTP/2 on the same path. In startup the window then grows by every byte the
peer acknowledges — the handshake's packets as well as the application's (RFC 9002
§7.3.1, TCP's slow start). Through an emulated 450 ms, 9 Mbps link, Chromium loading a
61 KB page that references a 61 KB script:
| | HTML after its first byte | the script | load |
|---|---|---|---|
| a 10-packet start | 934 ms (2 round trips) | 1384 ms | 2326 ms |
| 20 packets (default) | 490 ms (1) | 942 ms | 1890 ms |
The window's ceiling is 8 MB — what a long fat path needs at the pacing ceiling (14 MB/s × 450 ms ≈ 6.3 MB); a 4 MB download through the same link takes 5.4 s (it took 8.7 s under the earlier 300 KB ceiling). The window reaches it only where BBR measured that much: on a short path, the BDP keeps it small.
A returning client: Careful Resume
A client back within the hour has already shown this server its path. QUICO keeps what
BBR measured — the bottleneck bandwidth and the minimum RTT — in the client's session
ticket, and a connection that resumes with it starts from there, as RFC 9959 (Careful
Resume) lays out, with its BBR appendix — when turned on (carefulResume: true; off by
default, for reasons measured at the end of this section):
- Saved once BBR has a measurement worth keeping (a capacity of at least four initial
windows): during Startup at each round it grows by a quarter, then when it moves by a
quarter either way — in a NewSessionTicket sent after the handshake (lemon-tls
sendTicket()), inside the ticket's encryption: the client carries it, cannot read or forge it, and the server keeps nothing. A resumed connection carries it forward. - Not used past an hour, from another network (the client's IPv4 /24 or IPv6 /48 changed: a laptop moved from home to a café), or when the first flight shows another RTT — at most half, or over ten times, the saved one.
- Reconnaissance → jump → validation. The first flight goes out at the initial window, as on any connection. Once it is acknowledged without loss, the first time the sender has more than its window allows, the window jumps to half the saved capacity, paced over one round trip; slow start goes on from what that delivers.
- Safe Retreat. A loss while the jump is out is taken for congestion: the saved state is deleted, the window drops to half of what was actually delivered and holds until the jump is acknowledged, and BBR goes on in ProbeBW from there.
Chromium through the emulated link, the second download on a new connection resuming with the first one's ticket:
| Path | File | First visit | Returning, Careful Resume | Returning, without | |---|---|---|---|---| | 450 ms, 9 Mbps | 512 KB | 2365 ms | 1736 ms | 2384 ms | | 450 ms, 9 Mbps | 2 MB | 4107 ms | 3353 ms | 4152 ms | | 100 ms, 50 Mbps | 4 MB | 1876 ms | 1428 ms | 1634 ms | | 450 ms, 9 Mbps, 2 % random loss on the return | 2 MB | 4026 ms | 5357 ms | 4608 ms |
The last row is the RFC's price: a random loss during the jump looks like congestion, and the retreat costs more than QUICO's BBR loses without it — it does not react to loss at all. On a path that did get slower (the same RTT, a third of the rate), the jump is what the retreat is for; measured there, the returning download was still faster with it (6.8 s against 7.8 s), the queue having absorbed it.
Off by default. Those measurements were of one file, downloaded twice — so the first visit had measured the path at full rate. A website's first visit is a page: a document and its resources, which measure a lower rate, so the jump on the next visit is smaller. Measured again that way (Chromium, the second visit on a new connection), and with the handshake and loss recovery improved since, which made connections without it faster too:
| Path | Returning visit | With Careful Resume | Without | |---|---|---|---| | 100 ms, 50 Mbps | 4 MB download | 1314 ms | 1320 ms | | 450 ms, 9 Mbps | 512 KB download | 2833 ms | 2918 ms | | 100 ms, 50 Mbps | page (60 KB + 20 scripts) | 731 ms | 678 ms | | 250 ms, 20 Mbps | page | 1769 ms | 1660 ms | | 250 ms, 20 Mbps, 3 % random loss | page | 3583 ms | 2150 ms |
Almost nothing on clean paths, and a lot lost on a lossy one: with a hundred packets in the
jump and a few percent of random loss, one is nearly always lost, Safe Retreat takes it for
congestion, and the connection goes on at a fraction of the link. carefulResume: true
turns it on — for an application whose returning clients download large files over clean
paths, as in the first table; getStats().carefulResume gives a connection's phase.
Honest scope: this is BBR-style, not a certified BBRv2. ProbeRTT — the periodic cwnd collapse that re-measures RTprop on a permanently saturated path — is not implemented, and there is no explicit loss response. The windowed filters bound the damage of stale measurements in the meantime.
Stream scheduling: byte-level round-robin, by priority
The choice: when several streams have data ready and one packet is going out, who gets the space? Implementations differ sharply — many drain streams in priority or creation order, filling each one before moving on.
QUICO interleaves at the byte level, inside a single packet
(execute_quic_burst). The scheduler cycles through the
active streams, taking a chunk from each until the packet is full, then cycles again —
so a 1200-byte packet can carry STREAM frames from three different streams:
┌─────────────────────────────── one QUIC packet ───────────────────────────────┐
│ ACK │ STREAM(id=0, 450B) │ STREAM(id=4, 450B) │ STREAM(id=8, 400B) │
└───────────────────────────────────────────────────────────────────────────────┘The loop repeats while any stream still yields data and space remains (progress
flag), so a stream that runs dry doesn't hold a slot — the remaining bandwidth
redistributes to the others within the same packet.
Each packet starts where the last one left off. A stream takes what it has, up to
the room left — so a stream with plenty to send fills a whole packet on its own. If
every packet started from the lowest stream number, that stream would fill every
packet and the others would wait for it to finish: three 6 MB downloads ran one after
another. The scheduler remembers who opened the previous packet (rr_cursor) and starts
the next round just after it, so with three busy streams the packets go 0, 4, 8, 0, 4,
8… and the downloads progress at equal rates. The cost is fragmentation — more STREAM
frame headers per packet (~24 bytes each) than a drain-one-stream-at-a-time scheduler.
QUICO accepts that trade for fairness.
Priorities decide who takes part in a round. The streams with data are arranged in tiers, and a packet takes from the first tier with something to send; only if that runs dry does the next tier fill the rest of the same packet:
- by urgency, most urgent first — RFC 9218's
u=0..7, default 3; urgency −1 is HTTP/3's own control and QPACK streams, ahead of everything (a header block that refers to a QPACK entry stuck behind response bytes would block); - within an urgency, non-incremental streams go one at a time, by stream number, each a tier of its own — a stylesheet whole before the next;
- then the incremental ones, taking turns as above;
- a group (any object, given to
setStreamPriority) takes one turn in its round, and passes it to its member with the highestorderthat has something to send; equal orders take turns. This is WebTransport'ssendGroup/sendOrder, mapped in the WebTransport layer; QUIC only knows "streams that share one turn".
A stream nobody set a priority for takes turns at urgency 3 — as every stream did
before. The mechanism lives in QUIC (setStreamPriority(id, { urgency, incremental,
group, order })); the policy comes from above: HTTP/3 reads the client's priority
header and PRIORITY_UPDATE frames, the application can override them
(res.setPriority) — the client's later signals do not undo the application's decision
— and WebTransport maps its streams' sendGroup / sendOrder. A client asks for a
priority with the priority header on its request ('u=1, i') — QUICO's client: the
priority option, req.setPriority(). HTTP/2 has the same
rules in its own scheduler (h2.js), for the DATA that waits for a window or for the
socket; what the socket already holds leaves in the order it was written. An HTTP/2
server sends SETTINGS_NO_RFC7540_PRIORITIES = 1: it reads RFC 9218's signals, not
RFC 7540's priority tree.
A scheduler can only order what is waiting. A stream fed in small writes with
backpressure has little queued at any moment, and while its queue is empty the next
tier sends — so an application that wants a stream strictly first should hand it its
data ahead of time, not a chunk per 'drain'. Likewise a stream blocked by the peer's
flow control lets the next one go, rather than leaving the packet empty.
The subtle part falls straight out of the reconciliation model: the sender decides
what to send by asking which bytes aren't acked or in flight — but chunks selected
earlier in the same burst have no packet number yet, so they're in neither set, and
the next iteration would select them again. get_stream_chunks takes what it yields out
of missing_ranges at once, so the next iteration sees it as taken; the packet's number
records it in in_flight_ranges when it is sent. A packet that does not leave hands its
bytes back to missing. One packet can carry two pieces of one stream — new data and a
repaired gap — so a packet's entry in in_flight_ranges is a range list, read whole by
the ACK, the expiry timer and a stream reset.
Many streams on one connection. What the sender does per packet and per ACK does not walk every stream: each packet in flight records the streams it carries, so an ACK (and the expiry timer) visits those; the streams that hit flow control, and those whose FIN is still to go, are kept apart the same way. Walked, those loops were most of the CPU of a connection with many streams — a thousand concurrent responses on one connection ran at 25 Mbps on loopback, two thousand at 10. Now 1000 run at ~60 and 2000 at ~55, against ~70 with 200 (one core, client and server in one process). What remains per stream is the scheduler's arrangement of the streams with data, once per burst.
Writes go out once per tick. A write to a stream does not send: it asks for one send pass at the end of the current tick, and every write until then rides in it. A response written as headers, ten small writes and an end is one datagram, not fourteen. A pass for any other reason — an ACK, a timer — still runs at once and takes what is waiting.
Datagrams (RFC 9221) are never retransmitted, but they go under the same congestion
control: they wait in a queue, are taken into packets ahead of stream data, and the
packets that carry them count in flight (with nothing to resend). A datagram sent with
a priority (WebTransport's sendOrder / sendGroup) is not first: it takes its place
in its group, as a member at its order. While the path cannot
keep up the oldest are dropped — any that have waited 250 ms (configurable), and past
1 MB queued — since a late datagram is worth nothing. The peer's
max_datagram_frame_size is honoured.
The send queue: the application's buffers, not copies
What a stream holds for sending is the list of buffers the application wrote, by reference, each with the stream offset it starts at. A packet takes a view of one of them, or — where it straddles two — a copy of its own ~1200 bytes. Writes of up to 4 KB are the exception: they are gathered into a 16 KB buffer of the stream's own, so ten thousand one-byte writes are a handful of pieces. A buffer leaves the queue the moment the peer has acknowledged all of it.
The effect is on memory: res.end(file) holds the file once, not once per layer, and
any number of concurrent responses of the same Buffer share it. As with
net.Socket, a buffer passed to write() / end() must not be modified afterwards
— it is referenced until acknowledged, and a retransmission reads it again.
Backpressure on the sending side works as on a TCP socket. A write is complete —
its callback runs — once the stream has sent all but writableHighWaterMark of what
was written (bytes in flight are bounded by the congestion window, as the kernel
bounds them for TCP). So on HTTP/3 res.write() returns false and 'drain' follows,
and readable.pipe(res) reads at the client's pace: a 30 MB file piped to a browser
holds ~5 MB of buffers on the server, not the file. The same applies to WebTransport
streams and to tunnels (WebSocket over HTTP/3, CONNECT).
Within a stream: new data leads, gaps follow
Given the missing set, in what order do you drain it? QUICO walks it in two passes:
forward from the send cursor first (new data), then backfilling the gaps below it
(bytes whose packets were lost).
New data leads because it keeps the pipe full and the ACK clock running — the receiver
buffers out-of-order bytes anyway, and the gap gets repaired within the same burst
rather than a round-trip later. Both passes read from the same missing computation,
so there's no ordering conflict to arbitrate: it's one set, drained in two sweeps.
Flow control interacts here in a non-obvious way. Send-side limits cap the highest offset we may send, so they bind only new bytes. A repair re-sends offsets that were already inside the allowance when first sent — it consumes no budget and must never be blocked. Getting this wrong deadlocks the connection: at the edge of an exhausted window, the missing range itself becomes unsendable, and the peer can't rescue you, because the data it would open the window for is exactly the data that never arrived.
Loss detection: timers, and how we treat late ACKs
Because recovery itself is just the reconciliation pass, loss "detection" here means only one thing: deciding when to stop counting a packet's bytes as in flight. Two decisions worth calling out:
Late ACKs are honoured, not discarded. When the timer expires a packet, its stream ranges are parked in a limbo table rather than forgotten. If the ACK then arrives late — routine on a queued path — the bytes are credited to the delivery rate model, the pending retransmission is cancelled, and the loss counter is corrected. QUIC never reuses packet numbers, so unlike TCP there's no retransmission ambiguity: a late ACK is unambiguous evidence the data arrived, and discarding it distorts BtlBw exactly when the model needs accuracy most.
RTT samples are taken from those packets too — same reasoning, plus a subtle failure mode it prevents: a too-short timer expires packets before their ACKs land, and if those ACKs are then barred from producing RTT samples, the timer never learns that it's too short. The loop is self-sealing. Accepting the sample breaks it.
Optimistic ACKs are caught (RFC 9000 §21.4). Every 256–1023 packets, at random, one 1-RTT packet number is skipped; an ACK that covers it acknowledges a packet that was never sent, and closes the connection (PROTOCOL_VIOLATION). A peer acknowledging ahead of what arrived would otherwise inflate the congestion window at will. The send history keeps a zero-length placeholder for the skipped number, so its index math stays contiguous.
The PTO itself is srtt + max(4·rttvar, 1ms) + max_ack_delay. That last term is not
optional: peers may legitimately sit on an ACK for their full advertised delay (25 ms
is common), and a timer without it expires packets moments before their ACKs arrive.
The timer is the backstop, not the first word. On a new connection rttvar is half the first RTT sample, so the timer comes ~3 RTTs after a packet left — and a lost packet in a page's first response is exactly where those RTTs are paid. Two things come first:
- Loss by ACK: the time threshold (RFC 9002 §6.1.2). A packet is given up on once a
packet sent after it is acknowledged and
max(9/8·RTT, RTT + 5 ms)has passed since it was sent (RTT: the larger of srtt and the latest sample) — not the timer. Then exactly the timer's path: resent, parked for a late ACK, counted lost. The RFC's packet threshold (three later packets acknowledged) is left out on purpose: a packet that arrives out of order is not resent for that, only for being later than the threshold; the 5 ms floor keeps that so on short paths, where an eighth of the RTT is less than Wi-Fi's own retransmissions reorder by. A 60 KB response through a 200 ms path with one packet lost: ~10 ms longer than with none, where it was ~185 ms. - The tail loss probe (RFC 8985). The last packet of a response — or a request in
one packet — has no later one to be acknowledged: after
2·srtt + max_ack_delaywithout an ACK, a copy of its data goes as a new packet. Nothing is given up on (the original stays in flight; whichever arrives counts), one probe until an ACK comes, only once the handshake is confirmed, and only while the timer is further off.
Chromium through 250 ms with 3 % loss (a 60 KB page and 20 scripts): page load p75 2.41 s → 2.02 s; through 20 ms with 1 % loss and 5 ms jitter: median 474 → 419 ms.
Our own ACKs are delayed and batched (RFC 9000 §13.2). In the 1-RTT space an ACK
goes out once two ack-eliciting packets are owed — decided at the end of the
event-loop turn, so datagrams that arrived together get one ACK — at once for a
packet out of order (that is what lets the sender detect loss quickly), and
otherwise within max_ack_delay. Any packet we send anyway carries the ACK that is
owed, and the ACK Delay field reports how long it was held, so the peer can take it
out of its RTT. Initial and Handshake packets are acknowledged immediately, as the
RFC requires — in the handshake's flush, with whatever else those spaces send (see
the handshake). Before this, every ack-eliciting packet got an ACK packet of its own:
a 20 MB download had the receiver send ~18,000 of them; now ~1,200.
The ACK timer runs at max_ack_delay − 15 ms (10 ms against the 25 ms we
advertise): timers fire late by up to their granularity, ~15.6 ms on Windows, and
the peer's loss timer counts on our ACK arriving within the advertised value.
ACK ranges are capped at 32 (RFC 9000 §13.2.4 permits acking a subset). Under loss, packet-number gaps never close — a lost PN is gone forever, its data returns under a new PN — so an uncapped ACK frame grows with the cumulative loss count until it no longer fits in a packet. We measured exactly that against a line-rate sender: ACK packets inflating 325 B → 1017 B second by second, until they crossed the MTU and stopped being sendable at all.
The handshake: coalesced datagrams, its own loss detection
The handshake is the one place where every datagram must arrive before anything can go on — so it is built to send as few as it can (RFC 9000 §12.2):
- One flush, coalesced datagrams. Initial and Handshake packets are not sent as TLS produces each message. What the two spaces have to send — CRYPTO data neither acknowledged nor in flight, an ACK they owe — goes out at the end of the turn, in packets as full as the datagram allows, the packets in as few datagrams as they fit. The datagram is padded to 1200 bytes, not an Initial packet with zeros ahead of the Handshake packets that could have filled it. A server's whole flight (ServerHello, EncryptedExtensions, Certificate, CertificateVerify, Finished, and the ACK of the ClientHello) is one datagram with a small chain, where it was seven; a client's answer one, where it was up to eight.
- RTT from the first round trip. ACKs of Initial and Handshake packets give RTT samples, as 1-RTT ones do (RFC 9002 §4.1: RTT measurement is "unified across packet number spaces"); the client has one when its handshake completes, not only after its first 1-RTT packet is acknowledged.
- ACK-based loss detection, in these two spaces only. A packet is lost once a later one is acknowledged and three more are, or 9/8 of an RTT has passed (RFC 9002 §6.1); its range is sent again at once. The retransmission timer stays as the backstop. The 1-RTT space keeps the recovery described above.
- The client's anti-deadlock probe (RFC 9002 §6.2.2.1). Until one of its Handshake packets is acknowledged, a client keeps its timer even with nothing in flight — and sends a PING when it fires: a server held by its anti-amplification limit has no timer of its own, and waits for any datagram from the client.
- The first 1-RTT packet rides in the last handshake datagram. When 1-RTT keys exist, the flush's last datagram waits for the end of the turn, and the first 1-RTT packet made in it goes in it, last (a short header has no length): the server's SETTINGS with its flight, the client's request — with its control streams — with its Finished, in room the Initial's padding took anyway. A connection with one request: 8 datagrams where it was 13; before the response, one datagram each way after the ClientHello. Not where it would cost the server a round trip: a datagram the anti-amplification budget would have let through alone is not made too large for it.
- The peer's retransmission is news (RFC 9002 §6.2.3). Handshake data received again means the peer has not heard from us: what we sent in answer and is still unacknowledged goes again at once, with the ACK the packet is owed — a server seeing the ClientHello again, a client seeing the server's flight again — not a retransmission timeout (three RTTs on the first sample) later. Twice per connection at most. A 1-RTT packet that rode in a datagram found lost this way, or by the ACK-based detection above, is lost with it and sent again in the new datagram — the request does not wait for the 1-RTT space's own timeout because it travelled with the Finished. A late ACK for either still counts.
Chromium against a QUICO server through a 250 ms path with 3 % loss: time to first byte went from a median of 1182 ms to 516 ms (two round trips — the floor), and the page from 2.8 s to 2.0 s. QUICO's client through the same path (100 connections): the 90th percentile of time to first byte from ~1150 ms to ~850 ms, mostly the lost Finished-and-request datagram answered on the server's retransmission.
Path MTU discovery
Packets start at what every QUIC path carries — 1200 bytes of frames — and most paths carry more: ~1450 on Ethernet. Every byte more in a packet is a packet less, and a packet is an encryption, a system call and its bookkeeping — where a JavaScript sender spends its time: a 4 MB download goes out in ~16 % fewer packets at 1452.
A round trip after the handshake is confirmed — the first responses go first; a probe is
1.4 KB of padding a slow link would put ahead of them — the sender probes (DPLPMTUD,
RFC 8899 / RFC 9000 §14.3), in a send pass of its own if nothing else would run one (a
client that only downloads may have nothing to send), and after the data of the pass it
shares:
a PING padded to a size, sent in the paced flow of the connection, and acknowledged — by
its own packet number — only if that size crossed the path. Sizes are whole UDP datagrams.
The first probe is at the largest datagram the peer has sent on this path (the limit is
most often the peer's own link — a PPPoE line, a VPN — and the same both ways), then at the
ceiling (1452, and the peer's max_udp_payload_size), and past a failure a binary search
down to 16 bytes. A size fails after three unacknowledged probes; the search runs again ten
minutes after it ends. A probe carries no stream data: a lost one — and a probe too large is
lost by design — holds nothing back, and is no loss to congestion control (§14.4).
Black holes. The MTU can shrink mid-connection. Packets above the floor lost in a row, with none acknowledged since, are a suspicion, not a verdict — congestion loses packets in runs too (Startup's overshoot does, every connection). A probe of the current size settles it: acknowledged, it was congestion; lost three times, packets go back to 1200 and the search starts again later. A new path starts from 1200, as its congestion state does.
| Path (largest datagram) | Found | Probes dropped | |---|---|---| | Ethernet (1472) | 1452 — the ceiling | 0 | | a VPN (1392) | 1387, within the search's 16 bytes | ~9 | | 1452, cut to 1300 mid-download | back to 1200 after 3 confirming probes | — |
Flow control: consumption-based windows
The choice: when do you tell the peer it may send more? The naive trigger is
"bytes arrived"; QUICO slides its receive windows on consumption — a
MAX_STREAM_DATA / MAX_DATA update goes out once in-order data has been delivered
up the stack and half a window has been used, never for bytes still sitting out of
order in the reassembly buffer.
Where "consumed" is measured. For what the application reads — a request body on
the server, a response body on the client, a WebTransport stream on either side — it is
the application's read: the
bytes that have left the Node stream's buffer, counted after each read() (which
flowing mode, pipe() and async iteration all go through). A reader that reads
nothing holds the peer to one stream window; one that reads slowly sets the peer's
pace. Everything else — HTTP/3's own streams — is consumed at the hand-off from QUIC to the HTTP/3 layer, and bounded there by its
own limits (a HEADERS frame by the field-section size we advertise, control frames by
a fixed cap).
These bytes count in the connection's window too (initial_max_data, 1 MB by
default): a few streams that nobody reads can hold the whole connection. An
application with many parallel streams — MoQT's stream per group — reads or stops
(stopSending) each one, and sizes the windows for it with transportParams.
Autotuning. A window caps the peer at one window a round trip: 256 KB a stream is
10 Mbit/s at 200 ms. So, as Chromium and quiche do, a window the application consumed
half of within two round trips of the last update — the window is what limits, not the
path — doubles, up to 16 MB a stream and 24 MB the connection (a larger
transportParams value is kept as given); the connection's grows with its streams, to
1.5× the largest. It grows only with what is consumed, so a reader that falls behind
keeps the window it has. Measured through an emulated 20 Mbit/s, 200 ms link, a 4 MB
download by QUICO's client: 7.8 s before, 4.2 s now (Chromium: 3.1 s).
HTTP/2, over TCP. The client's stream window is 6 MB (Chrome's), not
HTTP/2's 64 KB, and the connection's 16 MB. Credit still goes back as the
application reads, so a response nobody reads stops at 6 MB. The 64 KB default held a
response to 64 KB a round trip: 16 MB through a 100 ms round trip took 52 s, and takes
under 1 s now. An application that wants less sets initialWindowSize on the request.
Reading the source
Files map one-to-one onto protocol layers (see
Project Structure), state lives in plain objects you can
console.log, and the dense parts carry comments explaining why, not just what.
Start at src/quic_connection.js and follow a packet in
from feedDatagram() or out from sendStream().
🔬 Interoperability
Everything above is a claim; this section is the receipt.
QUICO is tested with the QUIC Interop Runner, the standard cross-implementation test harness. Every test runs both directions (QUICO as server and as client) through a network simulator with configurable delay, bandwidth limits and packet loss.
| Peer implementation | Language | handshake | transfer | http3 |
|---|---|:---:|:---:|:---:|
| quic-go | Go | ✅ | ✅ | ✅ |
| ngtcp2 | C | ✅ | ✅ | ✅ |
| quiche (Cloudflare) | Rust | ✅ | ✅ | ✅ |
| picoquic | C | ✅ | ✅ | ✅ |
| aioquic | Python | ✅ | ✅ | ✅ |
| neqo (Firefox) | Rust | ✅ | ✅ | ✅ |
- handshake — TLS 1.3 handshake over QUIC completes
- transfer — 10 MB across multiple concurrent streams, through a 10 Mbps bottleneck with a shallow queue (i.e. with real packet loss)
- http3 — three concurrent HTTP/3 requests, which must share one QUIC connection
0-RTT over TCP is verified with OpenSSL both ways (s_client -early_data, s_server
-early_data: taken, refused and sent again, and after a HelloRetryRequest). Over QUIC,
0-RTT is verified with Chromium (its second visit's request in its first flight, and its
retry after a 425), and with aioquic and quic-go in both directions.
Additionally verified against production servers: Google, Cloudflare,
Facebook, Microsoft, LiteSpeed and nginx — including a 12.7 MB
download from cloudflaremirrors.com byte-for-byte.
📚 API Reference
QUICO mirrors the node:https API wherever possible. If a method or property is not
documented here, it likely behaves exactly as its node:https counterpart.
This chapter covers the HTTP/3 API first, then framework compatibility, WebTransport, and finally the low-level QUIC primitives for non-HTTP protocols.
quico.createServer([options][, requestListener])
Creates a server for HTTP/3, HTTP/2 and HTTP/1.1. Returns a server object with
listen(), close() and on().
Options
| Option | Type | Default | Description |
|---|---|---|---|
| key | Buffer \| string \| Array | — | Private key in PEM format (a string without ----- is read as a file path). Required unless SNICallback is used. An array — node:tls's form, keys or { pem, passphrase } — for several certificates of different kinds, each key paired with the chain in cert that carries its public key (see Post-quantum TLS). |
| cert | Buffer \| string \| Array | — | Certificate chain in PEM format (or a file path, as for key); an array, one chain per key. |
| ca | Buffer \| string \| Array | null | Additional trusted CAs. |
| SNICallback | Function | null | (servername, cb, info) => cb(null, secureContext) for multi-domain setups. info.transport is 'tcp' or 'quic'. |
| http3 | boolean | true | Listen for HTTP/3 over UDP. |
| http2 | boolean | true | Also listen for HTTP/2 over TCP (fallback for non-QUIC clients). |
| http1 | boolean | true | Also listen for HTTP/1.1 over TCP. |
| ALPNProtocols | string[] | — | ALPN names to accept, in preference order, as in node:tls. Served HTTP versions missing from the list are put first; naming a version that is disabled throws. |
| maxConnections | number | 10000 | Maximum concurrent QUIC connections. |
| ticketKeys | Buffer (48 bytes) | random | Session-ticket key, shared by TCP and QUIC. Pass a stable one to keep resumption working across restarts. |
| ech | { keys } | — | Encrypted Client Hello keys, TCP and QUIC alike: { keys: [{ config, privateKey, retry }] }, from quico.generateEchKey(). A key that does not match its config throws here. See Encrypted Client Hello. |
| earlyData | boolean | false | Accept 0-RTT — a returning client's request in its first flight, answered one round trip sooner: over HTTP/3, and over TLS 1.3 on TCP (HTTP/2, HTTP/1.1). Off by default: early data can be replayed. See 0-RTT. |
| earlyDataMaxAge | number (ms) | 10000 | 0-RTT: how far the age a client states for its ticket may be from what the server measures (RFC 8446 §8.3) — a captured first flight is good for this long at most. 1–600000. |
| earlyDataReplay | (id, ttl, cb) => void | in memory | 0-RTT's anti-replay store: cb(null, true) if id is new (and keep it ttl ms), cb(null, false) if seen. Share one (Redis, memcached) between servers that share ticketKeys. No answer in 100 ms, or an error: no 0-RTT, the handshake goes on. |
| earlyDataFilter | (req, cb) => void | GET, HEAD, OPTIONS | 0-RTT: whether a request that came early may be handled before the handshake completes — cb(null, true); otherwise the client gets 425 Too Early and sends it again after the handshake (RFC 8470). No answer in 100 ms: 425. |
| sessionTimeout | number | 7200 | Seconds a session ticket stays good, TCP and QUIC alike (node:tls's option; its default is 300). 0–604800 (RFC 8446's 7 days); 0 issues tickets that never resume. |
| requestCert, rejectUnauthorized | boolean | false, true | Client certificates, as in node:tls, on every version — HTTP/3 included — verified against ca. With rejectUnauthorized (the default) a client without a valid one is refused; with false it gets in, and req.socket.authorized says which. req.socket.getPeerCertificate() / authorizationError as on a TLSSocket; on a resumed connection, the certificate it proved on its first. |
| minVersion, maxVersion | string | 'TLSv1.2', 'TLSv1.3' | 'TLSv1.2' or 'TLSv1.3'. HTTP/3 is TLS 1.3 only: maxVersion: 'TLSv1.2' needs http3: false. |
| certificateCompression | string[] | boolean | true | The algorithms the server's certificate may go compressed in (RFC 8879), in order: ['brotli', 'zstd', 'zlib'] — the default, true, is all of them that Node has (zstd from 22.15). It goes compressed only to a client that offered one, and only when that comes out smaller. false: always plain. TCP and QUIC alike; a name unknown throws from createServer. |
| honorCipherOrder | boolean | false | As node:tls: the cipher suite by the server's order (ciphers). By default the client's — a client that asks for AES-256 first gets it. |
| ciphers, ecdhCurve, sigalgs | string | — | As node:tls takes them (OpenSSL's colon-separated names; ecdhCurve: 'X25519:P-256'). The server's default groups: every post-quantum one Node has, then X25519, P-256, P-384 (see Post-quantum TLS). HTTP/3 uses the TLS 1.3 suites of ciphers (AES-GCM and ChaCha20-Poly1305); a list without one needs http3: false. A value naming nothing usable throws from createServer. |
| handshakeTimeout | number | TCP 120000, QUIC 10000 | Milliseconds a TLS handshake may take. Over QUIC, counted from the connection's first packet, and on a server until the client's Finished is verified — not only until the server's own Finished has gone: a client that sends a ClientHello and nothing more holds the connection for this long, not for the idle timeout. |
| passphrase | string | — | For an encrypted key. |
| validateAddress | boolean | false | Validate client addresses with a QUIC Retry before any handshake work. |
| handshakeLoadThreshold | number | 500 | HTTP/3 handshakes under way at which 'handshakeLoad' fires (high: true), and again under half of it (high: false). 0: off. |
| maxHandshakesPerAddress | number | 64 | HTTP/3 handshakes under way from one client address; past it an Initial from there makes no connection. 0: no cap. |
| resetTokenSecret | Buffer (≥ 16 bytes) | random | Secret for QUIC stateless-reset tokens. Keep it stable across restarts so clients of a crashed instance get a reset instead of a timeout. |
| tokenSecret | Buffer (≥ 16 bytes) | random | Secret the HTTP/3 address-validation tokens (Retry, and NEW_TOKEN for a client's next connection) are sealed under — node:quic's name. Servers that share it open each other's tokens: several on one port (a thread each, SO_REUSEPORT), or one restarted. |
| socket | dgram.Socket | null | Use an externally-bound IPv4 UDP socket instead of creating one. Must already be bound. |
| socket6 | dgram.Socket | null | Same, for IPv6. |
| greaseQuicBit | boolean | true; false with socket / socket6 | QUIC: invite clients to send the fixed bit unpredictable (RFC 9287), so the bit stays free to change. Off by default on an external socket, whose port may be shared with STUN, TURN or DTLS — told apart from QUIC by that bit (RFC 9443). true when that port carries QUIC alone. |
| port | number | 443 | The port advertised in Alt-Svc when listen() is not used (externally fed server). |
| altSvc | string \| false | — | The Alt-Svc header on HTTPS HTTP/1.1 and HTTP/2 responses. By default h3=":<port>"; ma=86400 when this server runs HTTP/3, and none with http3: false. A string is sent as is — for HTTP/3 served by something else ('h3=":443"; ma=86400'); false sends none. A response's own alt-svc header wins. |
| connectUdp | object | — | CONNECT-UDP's policy: { template, allowPrivate, maxTunnelsPerConnection, idleTimeout, lookup, proxyName } — see CONNECT-UDP. |
| shouldUpgradeCallback | (req) => boolean | listens for 'upgrade'? | As in node:http: whether an upgrade request (HTTP/1.1 Upgrade, or extended CONNECT over HTTP/2 and HTTP/3) is taken up as 'upgrade', or handled as an ordinary 'request'. |
| headersTimeout | number | 60000 | How long a request's head may take to arrive. HTTP/1.1: 408 and close. HTTP/2: a header block left open (HEADERS without END_HEADERS) blocks the whole connection, so the connection goes (GOAWAY). HTTP/3: the request stream is reset, H3_REQUEST_INCOMPLETE. 0 disables it. |
| requestTimeout | number | 300000 | As node:http: the whole request, body included, must arrive within it, counted from the end of its head. HTTP/1.1: 408 and close. HTTP/2 and HTTP/3: that request's stream is reset (CANCEL / H3_REQUEST_INCOMPLETE) and the request gets 'aborted'; the connection serves on. Not applied to CONNECT (WebSocket, WebTransport), whose stream is meant to stay open. The response is not timed. 0 disables it. |
| keepAliveTimeout | number | 5000 | HTTP/1.1 only: an idle connection between requests. |
| streamResetBurst, streamResetRate | number | 1000, 33 | Rapid Reset (CVE-2023-44487) protection, node:http2's options and defaults: a client may cancel streamResetBurst requests at once, then streamResetRate a second. Past it the connection is closed — HTTP/2 GOAWAY ENHANCE_YOUR_CALM (a 'sessionError', ERR_HTTP2_STREAM_RESET_RATE), HTTP/3 H3_EXCESSIVE_LOAD. HTTP/3 counts cancelled request streams (RESET_STREAM or STOP_SENDING, once each), not a WebTransport session's own streams. Infinity for either: no limit. The 'stream_reset' event remains for a policy of your own. |
| maxRequestsPerSocket | number | 0 (no limit) | node:http's: requests one connection may carry. HTTP/1.1: the Nth response says Connection: close and the connection ends (a request past it, pipelined, gets 503). HTTP/2 and HTTP/3: GOAWAY after the Nth — requests in flight finish, the client takes the next to a new connection (nginx's keepalive_requests). |
| maxHeaderSize | number | 16384 | HTTP/1.1: request line plus headers, in bytes (node:http's option and default). Over it: 431. |
| maxHeaderCount | number | 2000 | HTTP/1.1: header lines. Over it: 431 (node:http drops the extra ones instead). |
| noDelay, keepAlive, keepAliveInitialDelay | | true, false, 0 | TCP socket options. |
| transportParams | object | — | QUIC's windows and stream limits, as sent to every client: initialMaxData, initialMaxStreamDataBidiLocal, initialMaxStreamDataBidiRemote, initialMaxStreamDataUni, initialMaxStreamsBidi, initialMaxStreamsUni, maxIdleTimeout. See Transport parameters. |
| initialCongestionWindow | number | 20 | QUIC: the congestion window a connection starts with, in full-size packets (1200 B), 2–100. See The first round trips. |
| carefulResume | boolean | false | QUIC: a returning client's connection starts from what the server measured on its last one (RFC 9959). Off by default: for page loads it gains almost nothing and costs a lot with random los
