fix: close QUIC streams after receiving FIN#99
Merged
Conversation
richard-ramos
force-pushed
the
closeIfDone
branch
from
July 13, 2026 18:33
5bf8103 to
50eabef
Compare
There was a problem hiding this comment.
Pull request overview
This PR addresses QUIC stream lifecycle handling so streams are properly closed after receiving a peer FIN (EOF), preventing peer-initiated stream credit from getting stuck and avoiding blocked handlers.
Changes:
- Add a lifecycle regression test that opens many streams and asserts close+EOF retires stream credit without timeouts.
- Introduce
closeIfDone()/requestClose()logic to close the underlying lsquic stream once bothcloseWriteandisEofare true, including on EOF read paths. - Bump package version to
0.6.0.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tests/test_lifecycle.nim | Adds a regression test for stream-credit retirement when close is followed by EOF. |
| lsquic/stream.nim | Implements close-on-(closeWrite+EOF) logic and integrates it into close/read paths. |
| lsquic/context/stream.nim | Triggers close-on-EOF from the lsquic read callback path. |
| lsquic.nimble | Updates package version. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
richard-ramos
marked this pull request as ready for review
July 13, 2026 19:59
richard-ramos
requested review from
gmelodie and
vladopajic
and removed request for
a team
July 13, 2026 19:59
vladopajic
approved these changes
Jul 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Retire QUIC streams once the local write side has been closed and the remote FIN has been observed.
Previously,
close()only requestedlsquic_stream_close()when EOF had already been seen. If EOF arrived later, the stream could remain unretired at the lsquic layer and keep peer-initiated stream credit consumed.This PR makes the final close step idempotent and triggers it from both direct reads and the
onReadcallback when EOF is reached.Impact on Library Users
No API migration is required. Existing users that close the write side and then read EOF should now release QUIC stream credit correctly.
Risk Assessment
This changes stream lifecycle behavior around EOF and close. The main risk is closing a stream too eagerly in edge cases where lsquic has not fully processed shutdown state; the close path is guarded to run only after local close and remote EOF are both observed.
Additional Notes
Adds a regression test that opens more than the default initial bidirectional stream credit to verify that close plus EOF retires peer-initiated streams.
References