Skip to content

fix: close QUIC streams after receiving FIN#99

Merged
richard-ramos merged 3 commits into
mainfrom
closeIfDone
Jul 14, 2026
Merged

fix: close QUIC streams after receiving FIN#99
richard-ramos merged 3 commits into
mainfrom
closeIfDone

Conversation

@richard-ramos

@richard-ramos richard-ramos commented Jul 13, 2026

Copy link
Copy Markdown
Member

Summary

Retire QUIC streams once the local write side has been closed and the remote FIN has been observed.

Previously, close() only requested lsquic_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 onRead callback 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

Copilot AI review requested due to automatic review settings July 13, 2026 18:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 both closeWrite and isEof are 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.

Comment thread lsquic/stream.nim
Comment thread lsquic/context/stream.nim Outdated
Copilot AI review requested due to automatic review settings July 13, 2026 18:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread lsquic/context/stream.nim Outdated
Copilot AI review requested due to automatic review settings July 13, 2026 19:37

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

Comment thread lsquic/stream.nim
Comment thread lsquic/stream.nim
Comment thread lsquic.nimble Outdated
Copilot AI review requested due to automatic review settings July 13, 2026 19:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Comment thread tests/test_lifecycle.nim
Comment thread tests/test_lifecycle.nim
@richard-ramos
richard-ramos marked this pull request as ready for review July 13, 2026 19:59
@richard-ramos
richard-ramos requested a review from a team as a code owner July 13, 2026 19:59
@richard-ramos
richard-ramos requested review from gmelodie and vladopajic and removed request for a team July 13, 2026 19:59
@richard-ramos
richard-ramos merged commit b778d16 into main Jul 14, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: using QUIC, Nimbus loses Lighthouse peers

3 participants