GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — QUIC: createStream() permanently consumes a stream ID on STREAM_LIMIT_ERROR; peerAllowedStreams() then over-reports and the connection degrades irreversibly · Issue #18310 · netty/netty

QUIC: createStream() permanently consumes a stream ID on STREAM_LIMIT_ERROR; peerAllowedStreams() then over-reports and the connection degrades irreversibly #18310

New issue
Copy link
New issue
Copy link
Closed
#18311
Closed
QUIC: createStream() permanently consumes a stream ID on STREAM_LIMIT_ERROR; peerAllowedStreams() then over-reports and the connection degrades irreversibly#18310
#18311
Copy link

Description

@Echo009
Echo009
opened on Nov 8, 2026
Issue body actions

Environment

  • Netty 4.2.18.Final (code path verified unchanged in 4.2.20.Final and current 4.2 branch HEAD)
  • netty-codec-classes-quic / netty-codec-native-quic (quiche pinned at 55886df3), Linux x86_64
  • Reproduced with a pure netty client + netty server over loopback (no third-party code)

Steps to reproduce

The existing QuicStreamLimitTest.testStreamLimitEnforcedWhenCreatingViaClient walks right up to this and stops: on the 4.2.18.Final tag it deliberately fails the second createStream (QuicStreamLimitTest.java:101-104), closes the stream, asserts peerAllowedStreams == 1 (:108) and then closes the connection (:109). Adding one more createStream at that point reproduces the defect:

  1. Server configured with initialMaxStreamsBidirectional(1).
  2. Client opens 1 stream → succeeds, peerAllowedStreams(BIDIRECTIONAL) == 0.
  3. Second createStream → fails with QuicException wrapping QuicTransportError(STREAM_LIMIT_ERROR).
  4. Close the first stream, wait for QuicStreamLimitChangedEvent / MAX_STREAMS.
  5. peerAllowedStreams(BIDIRECTIONAL) == 1 — as documented, one more stream can be created.
  6. Third createStream → still fails with STREAM_LIMIT_ERROR, and every subsequent attempt on this connection fails forever, while peerAllowedStreams keeps returning 1.

We keep this as a standalone regression-style test (runs green in under a second against the current behavior; it documents the defect and will flip red once fixed). Happy to attach it — it only uses netty classes.

Expected behavior

QuicChannel.peerAllowedStreams javadoc:

"Returns the number of streams that can be created before stream creation will fail with {@link QuicTransportError#STREAM_LIMIT_ERROR} error."

After the peer restores the limit and the method returns 1, the next createStream should succeed. Likewise QuicStreamLimitChangedEvent signals "stream limit restored", implying restored quota is usable.

Actual behavior / root cause

QuicheQuicChannel.connectStream allocates the stream ID before attempting the implicit open (idGenerator.nextStreamId(...) at QuicheQuicChannel.java:1543 on 4.2.18.Final), then drives the open via quiche_conn_stream_send. On failure the promise fails but the generator is never rolled back, so every failed attempt permanently advances the sequence of all future stream IDs on the connection.

quiche's implicit-open check is positional: get_or_create_stream rejects when max(local_opened_streams_bidi, id_sequence + 1) > peer_max_streams_bidi and advances nothing on rejection (quiche src/stream/mod.rs, pinned commit). Since peer_streams_left_bidi = peer_max_streams_bidi − local_opened_streams_bidi never counts failed attempts, the two views diverge: after N burned IDs, peerAllowedStreams() > 0 no longer implies the next createStream can succeed, and the only recovery is closing the connection.

A pool-style caller that follows the javadoc ("check peerAllowedStreams > 0, then createStream") still hits this at the limit boundary (concurrent attempts on the last slot), after which the connection keeps reporting capacity while every open fails — which is exactly how we found it in production.

For contrast, skipping IDs is of course RFC 9000-legal (§2.1 out-of-order use), and quiche's own h3 layer avoids the burn by only advancing next_uni_stream_id after a successful send ("To avoid skipping stream IDs, we only calculate the next available stream ID when data has been successfully buffered", quiche src/h3/mod.rs).

Suggested fix

Pre-check the cached bidiStreamsLeft / uniStreamsLeft > 0 in connectStream before allocating the ID, and fail fast with STREAM_LIMIT_ERROR otherwise. The "cache ≤ actual" invariant plus the fact that connectStream and the cache refresh both run on the connection eventloop make this airtight: if the pre-check passes, quiche's positional check passes too. Alternative: roll back QuicStreamIdGenerator on failure (safe for the same serialization reason — the failure branch completes before the next allocation).

Secondary observation while auditing this area: the cache refresh condition uniLeftOld == 0 || bidiLeftOld == 0 (QuicheQuicChannel.java:1754) uses == 0. A cached value that went negative (reachable in a narrow race: cache > 0 while MAX_STREAMS already arrived, then several opens succeed past zero within one batch) never matches == 0 again and peerAllowedStreams freezes below zero permanently. <= 0 (or clamping) would close that corner.

Activity

  1. Echo009
    added 4 commits that reference this issue on Nov 8, 2026

    Quic: don't permanently consume stream ids when createStream(...) fails

    This issue will close once commit 320a9ba is merged into the '4.2' branch.
    320a9ba

    Quic: don't permanently consume stream ids when createStream(...) fails

    This issue will close once commit 6a86656 is merged into the '4.2' branch.
    6a86656

    Quic: only trust refreshed stream credits for the fail-fast check

    This issue will close once commit 5c312c6 is merged into the '4.2' branch.
    5c312c6

    Quic: don't permanently consume stream ids when createStream(...) fails

    This issue will close once commit b64a112 is merged into the '4.2' branch.
    b64a112
  2. normanmaurer
    closed this as completedin #18311on Nov 9, 2026
  3. normanmaurer
    added a commit that references this issue on Nov 9, 2026

    Port 5: Quic: don't permanently consume stream ids when createStream(…

    1dd4cbc
  4. tuke-code
    added a commit that references this issue on Nov 9, 2026

    Quic: don't permanently consume stream ids when createStream(...) fai…

    f0dc37e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.