You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Why is there no callback for static conn_recv_max_data into application? #2243
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)
My expectation is that nghttp3 can handle this situation.
The typical packetization process is as follows:
If ngtcp2_conn_get_max_data_left2() returns 0, do not try to send HTTP/3 stream data.
If ngtcp2_conn_get_max_data_left2() > 0, call nghttp3_conn_writev_stream() to get a stream ID and data to send.
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.
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.
(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:
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?
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).
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?
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.
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)
.
Activity
tatsuhiro-t commentedon Jul 13, 2026
My expectation is that nghttp3 can handle this situation.
The typical packetization process is as follows:
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.
martenrichter commentedon Jul 14, 2026
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.
martenrichter commentedon Jul 16, 2026
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:
ngtcp2/lib/ngtcp2_conn.c
Line 3991 in 30866a4
So it tries to send an extension of stream max data, but the other side never receives it.
It bails out:
ngtcp2/lib/ngtcp2_conn.c
Line 4124 in 30866a4
or here:
ngtcp2/lib/ngtcp2_conn.c
Line 4077 in 30866a4
I have added some debug code:
and it shows:
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?
tatsuhiro-t commentedon Jul 16, 2026
Before "bailing out", it tries to send max_stream_data:
ngtcp2/lib/ngtcp2_conn.c
Line 4052 in 30866a4
martenrichter commentedon Jul 16, 2026
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).
tatsuhiro-t commentedon Jul 16, 2026
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?
martenrichter commentedon Jul 16, 2026
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.
martenrichter commentedon Jul 26, 2026
You were right, it was something else.
martenrichter commentedon Jul 28, 2026
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)
.
Add callback for extendmaxdata
Add callback for extendmaxdata
Add callback for extendmaxdata