kazu-yamamoto / h3spec

Test tool for error cases of QUIC and HTTP/3
BSD 3-Clause "New" or "Revised" License
29 stars 2 forks source link

STOP_SENDING for a closed or reset stream results in error #3

Closed Ruben2424 closed 3 weeks ago

Ruben2424 commented 3 weeks ago

The h3 repository uses h3spec for tests in ci. With some changes it displays following error: https://github.com/hyperium/h3/actions/runs/10340143789/job/28620383129#step:6:1210

        predicate failed on expected exception: QUICException
       TransportErrorIsSent StreamStateError "No such stream for STOP_SENDING"

This is because STOP_SENDING is sent for the request stream after h3-spec closed it (FIN or Reset).

The spec says that a sender could also receive the frames in any state because of delivery delay: https://www.rfc-editor.org/rfc/rfc9000.html#name-permitted-frame-types

The receiver only sends MAX_STREAM_DATA frames in the "Recv" state. A receiver MAY send a STOP_SENDING frame in any state where it has not received a RESET_STREAM frame -- that is, states other than "Reset Recvd" or "Reset Read". However, there is little value in sending a STOP_SENDING frame in the "Data Recvd" state, as all stream data has been received. A sender could receive either of these two types of frames in any state as a result of delayed delivery of packets.

Also related discussion in https://github.com/quinn-rs/quinn/pull/1965

kazu-yamamoto commented 3 weeks ago

Section 19.5 says:

A STOP_SENDING frame can be sent for streams in the "Recv" or "Size Known" states; see Section 3.2. Receiving a STOP_SENDING frame for a locally initiated stream that has not yet been created MUST be treated as a connection error of type STREAM_STATE_ERROR.

So, I should check if the stream is already created. In your case, the stream is already created but gone, thus STREAM_STATE_ERROR should not be sent.

kazu-yamamoto commented 3 weeks ago

@Ruben2424 I think this has been fixed. If you can create the h3spec binary by yourself, I should wait for your testing. If it is hard, I would like to release a new version of h3spec without your testing.

Ruben2424 commented 3 weeks ago

@Ruben2424 I think this has been fixed. If you can create the h3spec binary by yourself, I should wait for your testing. If it is hard, I would like to release a new version of h3spec without your testing.

Thanks for fixing it. I will try to build it myself, but i never used Haskell before so i dont know how hard it is. I will let you know if i manage it.

kazu-yamamoto commented 3 weeks ago

As you may know, the fix is done in https://github.com/kazu-yamamoto/quic. You should use the main branch of quic to build h3spec.

Ruben2424 commented 3 weeks ago

I managed to build it. And it seems to fix the error. Thanks again for helping me out.

kazu-yamamoto commented 3 weeks ago

h3spec v0.1.11 has been released: https://github.com/kazu-yamamoto/h3spec/releases/tag/v0.1.11

Thank you for this bug report!