fix: shutdown and stream lifecycle handling#83
Merged
Conversation
richard-ramos
requested review from
Copilot,
gmelodie and
vladopajic
and removed request for
a team and
Copilot
April 20, 2026 13:53
There was a problem hiding this comment.
Pull request overview
This PR hardens QUIC shutdown semantics and stream lifecycle behavior by introducing an explicit “running” state for contexts, splitting quiesce vs native teardown, and tightening error/edge-case handling (streams, connections, TLS cert conversion), with added tests covering the new behavior.
Changes:
- Introduces
QuicContext.runningwithstop()(quiesce) anddestroy()(native teardown), and guards engine operations/packet ingestion when not running. - Improves stream/connection lifecycle correctness: pending stream cancellation on server close, stronger stream write/flush/wantwrite/wantread error handling, and safer client dial GC ref cleanup.
- Fixes/extends TLS certificate DER conversion behavior (nil/invalid handling) and adds lifecycle/TLS tests for shutdown + late datagram cases.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
lsquic/context/context.nim |
Adds running state, guards engine operations, and splits stop() from destroy(). |
lsquic/context/io.nim |
Ignores datagrams when context is not running. |
lsquic/client.nim |
Updates client shutdown flow to stop() contexts before UDP close and destroy() after. |
lsquic/server.nim |
Updates listener shutdown ordering and fixes log message typo. |
lsquic/context/client.nim |
Ensures running=true and releases GC refs when dial fails. |
lsquic/context/server.nim |
Ensures running=true and cancels pending streams on server connection close. |
lsquic/connection.nim |
Processes engine after stream creation request to advance pending stream lifecycle. |
lsquic/stream.nim |
Tightens close/write error handling (flush/wantwrite) and fixes close typo. |
lsquic/context/stream.nim |
Improves blocked-read handling via wantread management and fixes log message. |
lsquic/certificates.nim |
Rejects nil X509 and ensures DER conversion only succeeds on positive length. |
tests/test_lifecycle.nim |
Adds coverage for late datagrams after context stop/destroy. |
tests/test_tlsconfig.nim |
Adds coverage for DER conversion success and nil rejection. |
lsquic/helpers/transportaddr.nim |
Fixes assertion message typo. |
.github/workflows/lint.yml |
Bumps NPH action version used in lint workflow. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
gmelodie
approved these changes
Apr 20, 2026
vladopajic
approved these changes
Apr 20, 2026
richard-ramos
force-pushed
the
fix/various-3
branch
from
April 20, 2026 18:12
7a3b492 to
d610f8e
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Improves QUIC context shutdown safety and stream lifecycle behavior.