Skip to content

Why is there no callback for static conn_recv_max_data into application? #2243

Closed

Description

@martenrichter

I am currently investigating a deadlock using a bidi webtransport echo stream (echo on the server and client is sending and receiving both ngtcp2 and nghttp3, node.js). Until now, I do not know the cause.
However, I stumbled upon, that there is no callback for the app if conn_recv_max_data(ngtcp2_conn *conn, const ngtcp2_max_data *fr) is called.
So the maximum data of the session is extended.

Imagine the following scenario, the stream max data is not exhausted, but the other max data is (and stream etc are blocking because of this=.
The other side sends an extend max data,. It is noted in the lib, but the application has no reason to reschedule all the streams and does not attempt to send data and the connection freezes.

I am not sure if this is the case, but I think it may be likely.

(@jasnell @pimterry probably relevant for the node.js implementation)

Activity

  1. tatsuhiro-t commented on Jul 13, 2026

    @tatsuhiro-t
    Member

    My expectation is that nghttp3 can handle this situation.

    The typical packetization process is as follows:

    1. If ngtcp2_conn_get_max_data_left2() returns 0, do not try to send HTTP/3 stream data.
    2. If ngtcp2_conn_get_max_data_left2() > 0, call nghttp3_conn_writev_stream() to get a stream ID and data to send.
    3. Call ngtcp2_conn_writev_stream(). If it returns NGTCP2_ERR_STREAM_DATA_BLOCKED, that means max stream data is depleted, call nghttp3_conn_block_stream() so that the stream is removed from scheduler until nghttp3_conn_unblock_stream() is called.

    So the blocked streams are removed from the nghttp3 scheduler. The next call of nghttp3_conn_writev_stream() would return the different stream that is waiting in the queue.

  2. martenrichter commented on Jul 14, 2026

    @martenrichter
    ContributorAuthor

    Ok, thanks. But there is another point in the node.js, buffers in their stream side also count into the ngtcp2_conn_get_max_data_left2() budget. It may be that this js part is not awakened properly. Anyhow, I will report back, when I really understand wqhat is causing the race condition.

  3. martenrichter commented on Jul 16, 2026

    @martenrichter
    ContributorAuthor

    I have a new idea what might cause the race condition. It is actually related to stream_max_data.
    I see when it stalls, that the code enters:

    rv = ngtcp2_frame_chain_objalloc_new(&nfrc, &conn->frc_objalloc);
    (Though node.js is on an older ngtcp2 version).
    So it tries to send an extension of stream max data, but the other side never receives it.
    It bails out:
    ngtcp2_conn_tx_strmq_pop(conn);

    or here:
    ngtcp2_conn_tx_strmq_pop(conn);

    I have added some debug code:

     printf("streamfrq %d %d\n", strm->tx.streamfrq == NULL, ngtcp2_ksl_len(strm->tx.streamfrq) == 0);
    

    and it shows:

    streamfrq 0 1
    

    I must admit, that I am not familiar enough with ngtcp2 internals to understand, what is happening here.
    Can this be the cause of the stall?
    What causes it, and where do I have to search for preventing it?

  4. tatsuhiro-t commented on Jul 16, 2026

    @tatsuhiro-t
    Member

    Before "bailing out", it tries to send max_stream_data:

    nfrc->fr.max_stream_data = (ngtcp2_max_stream_data){

  5. martenrichter commented on Jul 16, 2026

    @martenrichter
    ContributorAuthor

    Thanks, you say it "tries", so it fails? Or did it work?
    Because if it works, I have to find out why it does not arrive at the other side. (is the prepared packet not send out, or does it not arrive on the other side).

  6. tatsuhiro-t commented on Jul 16, 2026

    @tatsuhiro-t
    Member

    There are some failure cases such as packets are full or out of memory. They are not common. Maybe better to check your own server, client or nodejs implementation I guess rather than ngtcp2 implementation?

  7. martenrichter commented on Jul 16, 2026

    @martenrichter
    ContributorAuthor

    There are some failure cases such as packets are full or out of memory. They are not common. Maybe better to check your own server, client or nodejs implementation I guess rather than ngtcp2 implementation?

    Well, it is all nodejs using ngtcp2. And yes, I will probably now turn to the node.js side and check, why this particular packet is not send out or received.

  8. martenrichter commented on Jul 26, 2026

    @martenrichter
    ContributorAuthor

    You were right, it was something else.

  9. martenrichter commented on Jul 28, 2026

    @martenrichter
    ContributorAuthor

    I have thought about it (the callback). The problem is that node.js holds some buffers outside ngtcp2 and uses the budget from ngtcp2 flow control for backpressure. Thus if ngtcp2 buffers are empty and the buffers are hold on the node.js side, node.js is not informed that the limits are changed, so I think regardless if nghttp3 is properly informed, the node.js side so the app, needs a possibility to know that there is space available (in flow control)
    .

  10. added 3 commits that reference this issue on Aug 15, 2026
    5f4aa29
    96dae61
    cb0cfcf
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